|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
424 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | const IS_UNSIGNED_INTEGER = /^(?:0|[1-9]\d*)$/;
|
|---|
| 2 | function 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 |
|
|---|
| 16 | export { isIndex };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.