sign.js 314 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 var toNumber = require('../lang/toNumber'); /** * Get sign of the value. */ function sign(val) { var num = toNumber(val); if (num === 0) return num; // +0 and +0 === 0 if (isNaN(num)) return num; // NaN return num < 0? -1 : 1; } module.exports = sign;