math-sign.js 320 B

123456789
  1. 'use strict';
  2. // `Math.sign` method implementation
  3. // https://tc39.es/ecma262/#sec-math.sign
  4. // eslint-disable-next-line es/no-math-sign -- safe
  5. module.exports = Math.sign || function sign(x) {
  6. var n = +x;
  7. // eslint-disable-next-line no-self-compare -- NaN check
  8. return n === 0 || n !== n ? n : n < 0 ? -1 : 1;
  9. };