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