UNPKG

raptor-polyfill

Version:

Polyfills for various EcmaScript 5 and EcmaScript 6 methods distributed as CommonJS modules that can be require'd individually or as a whole.

12 lines 292 B
// ES5 9.4 // http://es5.github.com/#x9.4 // http://jsperf.com/to-integer module.exports = function(n) { n = +n; 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; };