2.3.0: Add options.decimalsRounding to format()
Allows to specify the rounding method used for the decimals.
// Using 4,569.988
const n = [456988n, 2] as const;
// With 1 digit
format(n, 1) // "4,569.9" (default rounding)
format(n, { // "4,569.8" (rounding down)
digits: 1,
decimalsRounding: "ROUND_DOWN"
})
// With 2 digits
format(n, 2) // "4,569.88" (default rounding)
format(n, { // "4,569.89" (rounding up)
digits: 2,
decimalsRounding: "ROUND_UP"
})