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

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 427 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const MAX_ARRAY_LENGTH = require('../_internal/MAX_ARRAY_LENGTH.js');
6const clamp = require('../math/clamp.js');
7
8function toLength(value) {
9 if (value == null) {
10 return 0;
11 }
12 const length = Math.floor(Number(value));
13 return clamp.clamp(length, 0, MAX_ARRAY_LENGTH.MAX_ARRAY_LENGTH);
14}
15
16exports.toLength = toLength;
Note: See TracBrowser for help on using the repository browser.