formatCurrency
Formats a number as localized currency using Intl.NumberFormat. The currency defaults to EUR, and the locale follows the package locale fallback unless a locale is provided explicitly.
Importing
ts
import { formatCurrency } from '@almighty-shogun/utils'Usage
ts
import { formatCurrency } from '@almighty-shogun/utils'
const total = formatCurrency(1299.5, 'EUR', 'nl');Parameters
| Name | Type | Description |
|---|---|---|
value | number | Value to format. |
currency | string | Currency code. Defaults to EUR. |
locale | string | Optional locale override. |
Returns
A localized currency string with exactly two fraction digits. Defaults to Euro formatting when no currency is provided.
Type signature
ts
declare function formatCurrency(
value: number,
currency?: string,
locale?: string
): string;