|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
846 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 |
|
|---|
| 5 | var IsInteger = require('./IsInteger');
|
|---|
| 6 |
|
|---|
| 7 | var isNegativeZero = require('math-intrinsics/isNegativeZero');
|
|---|
| 8 |
|
|---|
| 9 | var isTypedArray = require('is-typed-array');
|
|---|
| 10 | var typedArrayBuffer = require('typed-array-buffer');
|
|---|
| 11 |
|
|---|
| 12 | // https://262.ecma-international.org/11.0/#sec-isvalidintegerindex
|
|---|
| 13 |
|
|---|
| 14 | module.exports = function IsValidIntegerIndex(O, index) {
|
|---|
| 15 | if (!isTypedArray) {
|
|---|
| 16 | throw new $TypeError('Assertion failed: `O` must be a Typed Array');
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | typedArrayBuffer(O); // step 1
|
|---|
| 20 |
|
|---|
| 21 | if (typeof index !== 'number') {
|
|---|
| 22 | throw new $TypeError('Assertion failed: Type(index) is not Number'); // step 2
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | if (!IsInteger(index)) { return false; } // step 3
|
|---|
| 26 |
|
|---|
| 27 | if (isNegativeZero(index)) { return false; } // step 4
|
|---|
| 28 |
|
|---|
| 29 | if (index < 0 || index >= O.length) { return false; } // step 5
|
|---|
| 30 |
|
|---|
| 31 | return true; // step 6
|
|---|
| 32 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.