main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
887 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var $TypeError = require('es-errors/type');
|
---|
4 |
|
---|
5 | var IsDetachedBuffer = require('./IsDetachedBuffer');
|
---|
6 | var IsIntegralNumber = require('./IsIntegralNumber');
|
---|
7 |
|
---|
8 | var isNegativeZero = require('../helpers/isNegativeZero');
|
---|
9 |
|
---|
10 | var typedArrayBuffer = require('typed-array-buffer');
|
---|
11 |
|
---|
12 | // https://262.ecma-international.org/12.0/#sec-isvalidintegerindex
|
---|
13 |
|
---|
14 | module.exports = function IsValidIntegerIndex(O, index) {
|
---|
15 | // Assert: O is an Integer-Indexed exotic object.
|
---|
16 | var buffer = typedArrayBuffer(O); // step 1
|
---|
17 |
|
---|
18 | if (typeof index !== 'number') {
|
---|
19 | throw new $TypeError('Assertion failed: Type(index) is not Number');
|
---|
20 | }
|
---|
21 |
|
---|
22 | if (IsDetachedBuffer(buffer)) { return false; } // step 2
|
---|
23 |
|
---|
24 | if (!IsIntegralNumber(index)) { return false; } // step 3
|
---|
25 |
|
---|
26 | if (isNegativeZero(index)) { return false; } // step 4
|
---|
27 |
|
---|
28 | if (index < 0 || index >= O.length) { return false; } // step 5
|
---|
29 |
|
---|
30 | return true; // step 6
|
---|
31 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.