import { toClean } from "number-string";toClean(1.5009, {maxPrecision: 2}); // "1.5"
Parameters:
toClean(stringOrNumber, { decimalMark = ".", thousandSeparator = ",", maxPrecision = 10, // maximum precision possible is 10 to prevent floating point errors minPrecision = 0,});
.toMoney
Converts number to currency
import { toMoney } from "number-string";toMoney(-1234.5); // "($1,234.50)"
Parameters:
toMoney(stringOrNumber, { decimalMark = ".", thousandSeparator = ",", maxPrecision = 2, // maximum precision possible is 10 to prevent floating point errors minPrecision = 2, symbol = "$", symbolBehind = false, useParens = true,});
.toClosest
Rounds to the closest interval
import { toClosest } from "number-string";toClosest(12.6, 7.1); // 14.2