formatCurrency
Formats a number as localized currency using Intl.NumberFormat. 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
value: number
Value to format.
currency?: Undefinable<string>
Currency code.
Default: EUR
locale?: Undefinable<string>
Locale override.
Returns
A localized currency string with exactly two fraction digits. When no currency is provided, Euro formatting is used.Uses
Type signature
ts
declare function formatCurrency(
value: number,
currency?: Undefinable<string>,
locale?: Undefinable<string>
): string;