source: node_modules/es-toolkit/dist/compat/_internal/isIndex.mjs@ a762898

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

Added visualizations

  • Property mode set to 100644
File size: 424 bytes
Line 
1const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
2function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
3 switch (typeof value) {
4 case 'number': {
5 return Number.isInteger(value) && value >= 0 && value < length;
6 }
7 case 'symbol': {
8 return false;
9 }
10 case 'string': {
11 return IS_UNSIGNED_INTEGER.test(value);
12 }
13 }
14}
15
16export { isIndex };
Note: See TracBrowser for help on using the repository browser.