source: imaps-frontend/node_modules/es-abstract/2022/ToIndex.js

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: 638 bytes
RevLine 
[d565449]1'use strict';
2
3var $RangeError = require('es-errors/range');
4
5var ToIntegerOrInfinity = require('./ToIntegerOrInfinity');
6var ToLength = require('./ToLength');
7var SameValue = require('./SameValue');
8
9// https://262.ecma-international.org/8.0/#sec-toindex
10
11module.exports = function ToIndex(value) {
12 if (typeof value === 'undefined') {
13 return 0;
14 }
15 var integerIndex = ToIntegerOrInfinity(value);
16 if (integerIndex < 0) {
17 throw new $RangeError('index must be >= 0');
18 }
19 var index = ToLength(integerIndex);
20 if (!SameValue(integerIndex, index)) {
21 throw new $RangeError('index must be >= 0 and < 2 ** 53 - 1');
22 }
23 return index;
24};
Note: See TracBrowser for help on using the repository browser.