to-integer.js 282 B

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