|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
307 bytes
|
| Line | |
|---|
| 1 | import { MAX_ARRAY_LENGTH } from '../_internal/MAX_ARRAY_LENGTH.mjs';
|
|---|
| 2 | import { clamp } from '../math/clamp.mjs';
|
|---|
| 3 |
|
|---|
| 4 | function toLength(value) {
|
|---|
| 5 | if (value == null) {
|
|---|
| 6 | return 0;
|
|---|
| 7 | }
|
|---|
| 8 | const length = Math.floor(Number(value));
|
|---|
| 9 | return clamp(length, 0, MAX_ARRAY_LENGTH);
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | export { toLength };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.