-
Notifications
You must be signed in to change notification settings - Fork 4
Function.resolveNumberFormat
kodiakhq[bot] edited this page Sep 17, 2024
·
45 revisions
@sumup-oss/intl / resolveNumberFormat
resolveNumberFormat(
locales
?,options
?):null
|NumberFormat
Resolves the locale and collation options that are used to format a number.
Parameter | Type |
---|---|
locales ? |
string | string [] |
options ? |
NumberFormatOptions |
null
| NumberFormat
import { resolveNumberFormat } from '@sumup-oss/intl';
resolveNumberFormat();
// {
// 'locale': 'en-US',
// 'numberingSystem': 'latn',
// 'style': 'decimal',
// 'minimumIntegerDigits': 1,
// 'minimumFractionDigits': 0,
// 'maximumFractionDigits': 3,
// 'useGrouping': true,
// 'groupDelimiter': ',',
// 'decimalDelimiter': '.',
// }
resolveNumberFormat(['ban', 'id']);
// {
// 'locale': 'id',
// 'numberingSystem': 'latn',
// 'style': 'decimal',
// 'minimumIntegerDigits': 1,
// 'minimumFractionDigits': 0,
// 'maximumFractionDigits': 3,
// 'useGrouping': true,
// 'groupDelimiter': '.',
// 'decimalDelimiter': ',',
// }
resolveNumberFormat('en-GB', {
style: 'unit',
unit: 'liter',
unitDisplay: 'long',
});
// {
// 'locale': 'en-GB',
// 'numberingSystem': 'latn',
// 'style': 'unit',
// 'unit': 'liter',
// 'unitDisplay': 'long',
// 'minimumIntegerDigits': 1,
// 'minimumFractionDigits': 0,
// 'maximumFractionDigits': 3,
// 'useGrouping': true,
// 'notation': 'standard',
// 'signDisplay': 'auto',
// 'groupDelimiter': ',',
// 'decimalDelimiter': '.',
// }
For convenience, groupDelimiter
anddecimalDelimiter
are returned in
addition to the Intl.ResolvedNumberFormatOptions
.
In runtimes that don't support the Intl.NumberFormat.resolvedOptions
API,
null
is returned.