|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
520 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|---|
| 6 | function isIndex(value, length = Number.MAX_SAFE_INTEGER) {
|
|---|
| 7 | switch (typeof value) {
|
|---|
| 8 | case 'number': {
|
|---|
| 9 | return Number.isInteger(value) && value >= 0 && value < length;
|
|---|
| 10 | }
|
|---|
| 11 | case 'symbol': {
|
|---|
| 12 | return false;
|
|---|
| 13 | }
|
|---|
| 14 | case 'string': {
|
|---|
| 15 | return IS_UNSIGNED_INTEGER.test(value);
|
|---|
| 16 | }
|
|---|
| 17 | }
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | exports.isIndex = isIndex;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.