( valueInCents: number | bigint, options?: CurrencyFormatterOptions, )
| 6 | } |
| 7 | |
| 8 | export const currencyFormatter = ( |
| 9 | valueInCents: number | bigint, |
| 10 | options?: CurrencyFormatterOptions, |
| 11 | ) => { |
| 12 | const cents = toCentsNumber(valueInCents); |
| 13 | const currency = options?.currency || "USD"; |
| 14 | return Intl.NumberFormat("en-US", { |
| 15 | style: "currency", |
| 16 | currency, |
| 17 | trailingZeroDisplay: isZeroDecimalCurrency(currency) |
| 18 | ? "stripIfInteger" |
| 19 | : "auto", |
| 20 | ...options, |
| 21 | } as CurrencyFormatterOptions).format( |
| 22 | isZeroDecimalCurrency(currency) ? cents : cents / 100, |
| 23 | ); |
| 24 | }; |
no test coverage detected
searching dependent graphs…