formatCurrency
This helper function is used to format a currency value for a given locale. Intl.NumberFormat is used under the hood to format the currency.
Import
import { formatCurrency } from "@aeonkit/helpers";Parameters
formatCurrency accepts a single object as a parameter with the following properties:
amount
- amount
-
numberbigintThe amount to format.
options
See the Intl.NumberFormatOptions page for more information on what can be passed in.
- options?
-
Intl.NumberFormatOptionsThe options to format the currency.
locale
See the locales page for more information on what can be passed in.
- locale?
-
Intl.LocalesArgumentThe locale to format the currency.
Default:
en-US
Usage
Default
formatCurrency({ amount: 2390.45 })The above would yield the following output:
$2,390.45With Options
Here is an example with options:
formatCurrency({ amount: 2390.45, options: { currency: "EUR"} })The above would yield the following output:
€2,390.45Returns
The formatted currency value as a string.