source: imaps-frontend/node_modules/es-abstract/2021/IsValidIntegerIndex.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 891 bytes
RevLine 
[d565449]1'use strict';
2
3var $TypeError = require('es-errors/type');
[79a0317]4var isNegativeZero = require('math-intrinsics/isNegativeZero');
[d565449]5
6var IsDetachedBuffer = require('./IsDetachedBuffer');
7var IsIntegralNumber = require('./IsIntegralNumber');
8
9var typedArrayBuffer = require('typed-array-buffer');
10
11// https://262.ecma-international.org/12.0/#sec-isvalidintegerindex
12
13module.exports = function IsValidIntegerIndex(O, index) {
14 // Assert: O is an Integer-Indexed exotic object.
15 var buffer = typedArrayBuffer(O); // step 1
16
17 if (typeof index !== 'number') {
18 throw new $TypeError('Assertion failed: Type(index) is not Number');
19 }
20
21 if (IsDetachedBuffer(buffer)) { return false; } // step 2
22
23 if (!IsIntegralNumber(index)) { return false; } // step 3
24
25 if (isNegativeZero(index)) { return false; } // step 4
26
27 if (index < 0 || index >= O.length) { return false; } // step 5
28
29 return true; // step 6
30};
Note: See TracBrowser for help on using the repository browser.