8 lines
226 B
JavaScript
8 lines
226 B
JavaScript
![]() |
var trim = require('./trim');
|
||
|
|
||
|
module.exports = function toNumber(num, precision) {
|
||
|
if (num == null) return 0;
|
||
|
var factor = Math.pow(10, isFinite(precision) ? precision : 0);
|
||
|
return Math.round(num * factor) / factor;
|
||
|
};
|