to-integer-or-infinity.js 336 B

123456789
  1. var trunc = require('../internals/math-trunc');
  2. // `ToIntegerOrInfinity` abstract operation
  3. // https://tc39.es/ecma262/#sec-tointegerorinfinity
  4. module.exports = function (argument) {
  5. var number = +argument;
  6. // eslint-disable-next-line no-self-compare -- NaN check
  7. return number !== number || number === 0 ? 0 : trunc(number);
  8. };