source: imaps-frontend/node_modules/es-abstract/2018/ToIndex.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 620 bytes
Line 
1'use strict';
2
3var $RangeError = require('es-errors/range');
4
5var ToInteger = require('./ToInteger');
6var ToLength = require('./ToLength');
7var SameValueZero = require('./SameValueZero');
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 = ToInteger(value);
16 if (integerIndex < 0) {
17 throw new $RangeError('index must be >= 0');
18 }
19 var index = ToLength(integerIndex);
20 if (!SameValueZero(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.