to-integer-or-infinity.js 351 B

12345678910
  1. var ceil = Math.ceil;
  2. var floor = Math.floor;
  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 -- safe
  8. return number !== number || number === 0 ? 0 : (number > 0 ? floor : ceil)(number);
  9. };