toNumber.js 195 B

12345
  1. module.exports = function toNumber(num, precision) {
  2. if (num == null) return 0;
  3. var factor = Math.pow(10, isFinite(precision) ? precision : 0);
  4. return Math.round(num * factor) / factor;
  5. };