to-integer.js 279 B

123456789101112
  1. 'use strict';
  2. var sign = require('../math/sign')
  3. , abs = Math.abs, floor = Math.floor;
  4. module.exports = function (value) {
  5. if (isNaN(value)) return 0;
  6. value = Number(value);
  7. if ((value === 0) || !isFinite(value)) return value;
  8. return sign(value) * floor(abs(value));
  9. };