ToIntegerOrInfinity.js 340 B

123456789101112131415
  1. 'use strict';
  2. var ES5ToInteger = require('../5/ToInteger');
  3. var ToNumber = require('./ToNumber');
  4. // https://www.ecma-international.org/ecma-262/11.0/#sec-tointeger
  5. module.exports = function ToInteger(value) {
  6. var number = ToNumber(value);
  7. if (number !== 0) {
  8. number = ES5ToInteger(number);
  9. }
  10. return number === 0 ? 0 : number;
  11. };