1 | ;
|
2 | var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
|
3 | var toLength = require('../internals/to-length');
|
4 |
|
5 | var $RangeError = RangeError;
|
6 |
|
7 | // `ToIndex` abstract operation
|
8 | // https://tc39.es/ecma262/#sec-toindex
|
9 | module.exports = function (it) {
|
10 | if (it === undefined) return 0;
|
11 | var number = toIntegerOrInfinity(it);
|
12 | var length = toLength(number);
|
13 | if (number !== length) throw new $RangeError('Wrong length or index');
|
14 | return length;
|
15 | };
|