Function.formatCurrency - sumup-oss/intl-js GitHub Wiki
@sumup-oss/intl / formatCurrency
Function: formatCurrency()
formatCurrency(
value,locales?,currency?,options?):string
Defined in: lib/number-format/index.ts:87
Formats a number in the country's official currency with support for various notations.
Parameters
| Parameter | Type |
|---|---|
value |
number |
locales? |
string | string[] |
currency? |
string |
options? |
NumberFormatOptions |
Returns
string
Example
import { formatCurrency } from '@sumup-oss/intl';
formatCurrency(12345.67, 'de-DE'); // '12.345,67 €'
formatCurrency(89, 'ja-JP', 'JPY'); // '¥89'
formatCurrency(16, 'en-GB', null, { currencyDisplay: 'name' }); // '16.00 British pounds'
Remarks
In runtimes that don't support the Intl.NumberFormat API, the currency is
formatted using the Number.toLocaleString API.
The COP and HUF currencies are formatted without decimals.