_to-index.js 339 B

12345678910
  1. // https://tc39.github.io/ecma262/#sec-toindex
  2. var toInteger = require('./_to-integer');
  3. var toLength = require('./_to-length');
  4. module.exports = function (it) {
  5. if (it === undefined) return 0;
  6. var number = toInteger(it);
  7. var length = toLength(number);
  8. if (number !== length) throw RangeError('Wrong length!');
  9. return length;
  10. };