scurker / currency.js

A javascript library for handling currencies
https://currency.js.org
MIT License
3.15k stars 142 forks source link

Is there any way to set precision to all amounts? #448

Closed AlbertoJALJ closed 10 months ago

Ryiski commented 10 months ago

@AlbertoJALJ in a global way? Nop.

It's easy tho, just create your own re-useable solution

import currencyJs from "currency.js";

const currency = (
  value: string | number | currencyJs,
  opts?: currencyJs.Options | undefined
) => currencyJs(value, { ...opts, precision: opts?.precision || 0.2, });