to-integer-or-infinity.js 350 B

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