source: node_modules/es-toolkit/dist/compat/util/toLength.mjs

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 
1import { MAX_ARRAY_LENGTH } from '../_internal/MAX_ARRAY_LENGTH.mjs';
2import { clamp } from '../math/clamp.mjs';
3
4function 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
12export { toLength };
Note: See TracBrowser for help on using the repository browser.