|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
656 bytes
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Converts the value to a valid index. A valid index is an integer that is greater than or equal to `0` and less than or equal to `2^32 - 1`.
|
|---|
| 3 | *
|
|---|
| 4 | * It converts the given value to a number and floors it to an integer. If the value is less than `0`, it returns `0`. If the value exceeds `2^32 - 1`, it returns `2^32 - 1`.
|
|---|
| 5 | *
|
|---|
| 6 | * @param {unknown} value - The value to convert to a valid index.
|
|---|
| 7 | * @returns {number} The converted value.
|
|---|
| 8 | *
|
|---|
| 9 | * @example
|
|---|
| 10 | * toLength(3.2) // => 3
|
|---|
| 11 | * toLength(-1) // => 0
|
|---|
| 12 | * toLength(1.9) // => 1
|
|---|
| 13 | * toLength('42') // => 42
|
|---|
| 14 | * toLength(null) // => 0
|
|---|
| 15 | */
|
|---|
| 16 | declare function toLength(value: any): number;
|
|---|
| 17 |
|
|---|
| 18 | export { toLength };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.