Skip to content

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

NameTypeDescription
valuenumberValue to format.
currencystringCurrency code. Defaults to EUR.
localestringOptional 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;

All packages are released under the MIT License.