Variable.formatCurrency - sumup-oss/intl-js GitHub Wiki
@sumup-oss/intl / formatCurrency
Variable: formatCurrency
constformatCurrency: (value, ...args) =>string
Defined in: lib/number-format/index.ts:96
Formats a number as currency with support for various notations.
Parameters
| Parameter | Type |
|---|---|
value |
number |
...args |
[string | string[], string, NumberFormatOptions] |
Returns
string
Example
import { formatCurrency } from '@sumup-oss/intl';
formatCurrency(12345.67, 'de-DE', 'EUR'); // '12.345,67 €'
formatCurrency(89, 'ja-JP', 'JPY'); // '¥89'
formatCurrency(16, 'en-GB', 'GBP', { currencyDisplay: 'name' }); // '16.00 British pounds'
Remarks
When currency is omitted, it is inferred from the locale's region. This behavior
is deprecated — always pass an explicit currency code.
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.