UNPKG

holyfills

Version:

No more "Holy Sxxt!!" when writting ES5/ES6

15 lines (13 loc) 303 B
"use strict"; // ES5 9.4 // http://es5.github.com/#x9.4 // http://jsperf.com/to-integer module.exports = function (num) { var n = +num; if (n !== n) { // isNaN n = 0; } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) { n = (n > 0 || -1) * Math.floor(Math.abs(n)); } return n; };