@formatjs/ecma402-abstract 1.11.8 → 1.11.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/262.ts +372 -0
- package/BUILD +97 -0
- package/CHANGELOG.md +709 -0
- package/CanonicalizeLocaleList.ts +8 -0
- package/CanonicalizeTimeZoneName.ts +29 -0
- package/CoerceOptionsToObject.ts +13 -0
- package/DefaultNumberOption.ts +28 -0
- package/GetNumberOption.ts +29 -0
- package/GetOption.ts +38 -0
- package/GetOptionsObject.ts +14 -0
- package/IsSanctionedSimpleUnitIdentifier.ts +66 -0
- package/IsValidTimeZoneName.ts +27 -0
- package/IsWellFormedCurrencyCode.ts +23 -0
- package/IsWellFormedUnitIdentifier.ts +32 -0
- package/LICENSE.md +0 -0
- package/NumberFormat/ComputeExponent.ts +49 -0
- package/NumberFormat/ComputeExponentForMagnitude.ts +71 -0
- package/NumberFormat/CurrencyDigits.ts +13 -0
- package/NumberFormat/FormatNumericToParts.ts +22 -0
- package/NumberFormat/FormatNumericToString.ts +71 -0
- package/NumberFormat/InitializeNumberFormat.ts +147 -0
- package/NumberFormat/PartitionNumberPattern.ts +86 -0
- package/NumberFormat/SetNumberFormatDigitOptions.ts +45 -0
- package/NumberFormat/SetNumberFormatUnitOptions.ts +77 -0
- package/NumberFormat/ToRawFixed.ts +56 -0
- package/NumberFormat/ToRawPrecision.ts +86 -0
- package/NumberFormat/digit-mapping.generated.ts +1 -0
- package/NumberFormat/format_to_parts.ts +571 -0
- package/PartitionPattern.ts +38 -0
- package/README.md +0 -0
- package/SupportedLocales.ts +31 -0
- package/data.ts +9 -0
- package/index.ts +45 -0
- package/package.json +3 -3
- package/regex.generated.ts +2 -0
- package/scripts/digit-mapping.ts +109 -0
- package/scripts/regex-gen.ts +19 -0
- package/tests/PartitionPattern.test.ts +38 -0
- package/tests/ToRawFixed.test.tsx +41 -0
- package/tests/ToRawPrecision.test.tsx +65 -0
- package/tsconfig.json +5 -0
- package/types/core.ts +11 -0
- package/types/date-time.ts +199 -0
- package/types/displaynames.ts +48 -0
- package/types/list.ts +22 -0
- package/types/number.ts +240 -0
- package/types/plural-rules.ts +18 -0
- package/types/relative-time.ts +74 -0
- package/utils.ts +128 -0
- package/262.d.ts +0 -92
- package/262.d.ts.map +0 -1
- package/262.js +0 -362
- package/CanonicalizeLocaleList.d.ts +0 -6
- package/CanonicalizeLocaleList.d.ts.map +0 -1
- package/CanonicalizeLocaleList.js +0 -12
- package/CanonicalizeTimeZoneName.d.ts +0 -9
- package/CanonicalizeTimeZoneName.d.ts.map +0 -1
- package/CanonicalizeTimeZoneName.js +0 -21
- package/CoerceOptionsToObject.d.ts +0 -7
- package/CoerceOptionsToObject.d.ts.map +0 -1
- package/CoerceOptionsToObject.js +0 -16
- package/DefaultNumberOption.d.ts +0 -9
- package/DefaultNumberOption.d.ts.map +0 -1
- package/DefaultNumberOption.js +0 -14
- package/GetNumberOption.d.ts +0 -10
- package/GetNumberOption.d.ts.map +0 -1
- package/GetNumberOption.js +0 -18
- package/GetOption.d.ts +0 -10
- package/GetOption.d.ts.map +0 -1
- package/GetOption.js +0 -35
- package/GetOptionsObject.d.ts +0 -7
- package/GetOptionsObject.d.ts.map +0 -1
- package/GetOptionsObject.js +0 -18
- package/IsSanctionedSimpleUnitIdentifier.d.ts +0 -14
- package/IsSanctionedSimpleUnitIdentifier.d.ts.map +0 -1
- package/IsSanctionedSimpleUnitIdentifier.js +0 -68
- package/IsValidTimeZoneName.d.ts +0 -10
- package/IsValidTimeZoneName.d.ts.map +0 -1
- package/IsValidTimeZoneName.js +0 -23
- package/IsWellFormedCurrencyCode.d.ts +0 -5
- package/IsWellFormedCurrencyCode.d.ts.map +0 -1
- package/IsWellFormedCurrencyCode.js +0 -25
- package/IsWellFormedUnitIdentifier.d.ts +0 -6
- package/IsWellFormedUnitIdentifier.d.ts.map +0 -1
- package/IsWellFormedUnitIdentifier.js +0 -32
- package/NumberFormat/ComputeExponent.d.ts +0 -12
- package/NumberFormat/ComputeExponent.d.ts.map +0 -1
- package/NumberFormat/ComputeExponent.js +0 -43
- package/NumberFormat/ComputeExponentForMagnitude.d.ts +0 -10
- package/NumberFormat/ComputeExponentForMagnitude.d.ts.map +0 -1
- package/NumberFormat/ComputeExponentForMagnitude.js +0 -64
- package/NumberFormat/CurrencyDigits.d.ts +0 -7
- package/NumberFormat/CurrencyDigits.d.ts.map +0 -1
- package/NumberFormat/CurrencyDigits.js +0 -14
- package/NumberFormat/FormatNumericToParts.d.ts +0 -5
- package/NumberFormat/FormatNumericToParts.d.ts.map +0 -1
- package/NumberFormat/FormatNumericToParts.js +0 -18
- package/NumberFormat/FormatNumericToString.d.ts +0 -9
- package/NumberFormat/FormatNumericToString.d.ts.map +0 -1
- package/NumberFormat/FormatNumericToString.js +0 -45
- package/NumberFormat/InitializeNumberFormat.d.ts +0 -13
- package/NumberFormat/InitializeNumberFormat.d.ts.map +0 -1
- package/NumberFormat/InitializeNumberFormat.js +0 -68
- package/NumberFormat/PartitionNumberPattern.d.ts +0 -8
- package/NumberFormat/PartitionNumberPattern.d.ts.map +0 -1
- package/NumberFormat/PartitionNumberPattern.js +0 -80
- package/NumberFormat/SetNumberFormatDigitOptions.d.ts +0 -6
- package/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +0 -1
- package/NumberFormat/SetNumberFormatDigitOptions.js +0 -40
- package/NumberFormat/SetNumberFormatUnitOptions.d.ts +0 -8
- package/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +0 -1
- package/NumberFormat/SetNumberFormatUnitOptions.js +0 -43
- package/NumberFormat/ToRawFixed.d.ts +0 -10
- package/NumberFormat/ToRawFixed.d.ts.map +0 -1
- package/NumberFormat/ToRawFixed.js +0 -55
- package/NumberFormat/ToRawPrecision.d.ts +0 -3
- package/NumberFormat/ToRawPrecision.d.ts.map +0 -1
- package/NumberFormat/ToRawPrecision.js +0 -78
- package/NumberFormat/digit-mapping.generated.d.ts +0 -2
- package/NumberFormat/digit-mapping.generated.d.ts.map +0 -1
- package/NumberFormat/digit-mapping.generated.js +0 -4
- package/NumberFormat/format_to_parts.d.ts +0 -22
- package/NumberFormat/format_to_parts.d.ts.map +0 -1
- package/NumberFormat/format_to_parts.js +0 -424
- package/PartitionPattern.d.ts +0 -9
- package/PartitionPattern.d.ts.map +0 -1
- package/PartitionPattern.js +0 -39
- package/SupportedLocales.d.ts +0 -10
- package/SupportedLocales.d.ts.map +0 -1
- package/SupportedLocales.js +0 -24
- package/data.d.ts +0 -6
- package/data.d.ts.map +0 -1
- package/data.js +0 -17
- package/index.d.ts +0 -37
- package/index.d.ts.map +0 -1
- package/index.js +0 -48
- package/lib/262.d.ts +0 -92
- package/lib/262.d.ts.map +0 -1
- package/lib/262.js +0 -336
- package/lib/CanonicalizeLocaleList.d.ts +0 -6
- package/lib/CanonicalizeLocaleList.d.ts.map +0 -1
- package/lib/CanonicalizeLocaleList.js +0 -8
- package/lib/CanonicalizeTimeZoneName.d.ts +0 -9
- package/lib/CanonicalizeTimeZoneName.d.ts.map +0 -1
- package/lib/CanonicalizeTimeZoneName.js +0 -17
- package/lib/CoerceOptionsToObject.d.ts +0 -7
- package/lib/CoerceOptionsToObject.d.ts.map +0 -1
- package/lib/CoerceOptionsToObject.js +0 -12
- package/lib/DefaultNumberOption.d.ts +0 -9
- package/lib/DefaultNumberOption.d.ts.map +0 -1
- package/lib/DefaultNumberOption.js +0 -10
- package/lib/GetNumberOption.d.ts +0 -10
- package/lib/GetNumberOption.d.ts.map +0 -1
- package/lib/GetNumberOption.js +0 -14
- package/lib/GetOption.d.ts +0 -10
- package/lib/GetOption.d.ts.map +0 -1
- package/lib/GetOption.js +0 -31
- package/lib/GetOptionsObject.d.ts +0 -7
- package/lib/GetOptionsObject.d.ts.map +0 -1
- package/lib/GetOptionsObject.js +0 -14
- package/lib/IsSanctionedSimpleUnitIdentifier.d.ts +0 -14
- package/lib/IsSanctionedSimpleUnitIdentifier.d.ts.map +0 -1
- package/lib/IsSanctionedSimpleUnitIdentifier.js +0 -63
- package/lib/IsValidTimeZoneName.d.ts +0 -10
- package/lib/IsValidTimeZoneName.d.ts.map +0 -1
- package/lib/IsValidTimeZoneName.js +0 -19
- package/lib/IsWellFormedCurrencyCode.d.ts +0 -5
- package/lib/IsWellFormedCurrencyCode.d.ts.map +0 -1
- package/lib/IsWellFormedCurrencyCode.js +0 -21
- package/lib/IsWellFormedUnitIdentifier.d.ts +0 -6
- package/lib/IsWellFormedUnitIdentifier.d.ts.map +0 -1
- package/lib/IsWellFormedUnitIdentifier.js +0 -28
- package/lib/NumberFormat/ComputeExponent.d.ts +0 -12
- package/lib/NumberFormat/ComputeExponent.d.ts.map +0 -1
- package/lib/NumberFormat/ComputeExponent.js +0 -39
- package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts +0 -10
- package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts.map +0 -1
- package/lib/NumberFormat/ComputeExponentForMagnitude.js +0 -60
- package/lib/NumberFormat/CurrencyDigits.d.ts +0 -7
- package/lib/NumberFormat/CurrencyDigits.d.ts.map +0 -1
- package/lib/NumberFormat/CurrencyDigits.js +0 -10
- package/lib/NumberFormat/FormatNumericToParts.d.ts +0 -5
- package/lib/NumberFormat/FormatNumericToParts.d.ts.map +0 -1
- package/lib/NumberFormat/FormatNumericToParts.js +0 -14
- package/lib/NumberFormat/FormatNumericToString.d.ts +0 -9
- package/lib/NumberFormat/FormatNumericToString.d.ts.map +0 -1
- package/lib/NumberFormat/FormatNumericToString.js +0 -41
- package/lib/NumberFormat/InitializeNumberFormat.d.ts +0 -13
- package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +0 -1
- package/lib/NumberFormat/InitializeNumberFormat.js +0 -64
- package/lib/NumberFormat/PartitionNumberPattern.d.ts +0 -8
- package/lib/NumberFormat/PartitionNumberPattern.d.ts.map +0 -1
- package/lib/NumberFormat/PartitionNumberPattern.js +0 -75
- package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts +0 -6
- package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +0 -1
- package/lib/NumberFormat/SetNumberFormatDigitOptions.js +0 -36
- package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts +0 -8
- package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +0 -1
- package/lib/NumberFormat/SetNumberFormatUnitOptions.js +0 -39
- package/lib/NumberFormat/ToRawFixed.d.ts +0 -10
- package/lib/NumberFormat/ToRawFixed.d.ts.map +0 -1
- package/lib/NumberFormat/ToRawFixed.js +0 -51
- package/lib/NumberFormat/ToRawPrecision.d.ts +0 -3
- package/lib/NumberFormat/ToRawPrecision.d.ts.map +0 -1
- package/lib/NumberFormat/ToRawPrecision.js +0 -74
- package/lib/NumberFormat/digit-mapping.generated.d.ts +0 -2
- package/lib/NumberFormat/digit-mapping.generated.d.ts.map +0 -1
- package/lib/NumberFormat/digit-mapping.generated.js +0 -1
- package/lib/NumberFormat/format_to_parts.d.ts +0 -22
- package/lib/NumberFormat/format_to_parts.d.ts.map +0 -1
- package/lib/NumberFormat/format_to_parts.js +0 -421
- package/lib/PartitionPattern.d.ts +0 -9
- package/lib/PartitionPattern.d.ts.map +0 -1
- package/lib/PartitionPattern.js +0 -35
- package/lib/SupportedLocales.d.ts +0 -10
- package/lib/SupportedLocales.d.ts.map +0 -1
- package/lib/SupportedLocales.js +0 -20
- package/lib/data.d.ts +0 -6
- package/lib/data.d.ts.map +0 -1
- package/lib/data.js +0 -13
- package/lib/index.d.ts +0 -37
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -34
- package/lib/regex.generated.d.ts +0 -2
- package/lib/regex.generated.d.ts.map +0 -1
- package/lib/regex.generated.js +0 -2
- package/lib/types/core.d.ts +0 -11
- package/lib/types/core.d.ts.map +0 -1
- package/lib/types/core.js +0 -1
- package/lib/types/date-time.d.ts +0 -135
- package/lib/types/date-time.d.ts.map +0 -1
- package/lib/types/date-time.js +0 -6
- package/lib/types/displaynames.d.ts +0 -47
- package/lib/types/displaynames.d.ts.map +0 -1
- package/lib/types/displaynames.js +0 -1
- package/lib/types/list.d.ts +0 -19
- package/lib/types/list.d.ts.map +0 -1
- package/lib/types/list.js +0 -1
- package/lib/types/number.d.ts +0 -147
- package/lib/types/number.d.ts.map +0 -1
- package/lib/types/number.js +0 -1
- package/lib/types/plural-rules.d.ts +0 -17
- package/lib/types/plural-rules.d.ts.map +0 -1
- package/lib/types/plural-rules.js +0 -1
- package/lib/types/relative-time.d.ts +0 -41
- package/lib/types/relative-time.d.ts.map +0 -1
- package/lib/types/relative-time.js +0 -1
- package/lib/utils.d.ts +0 -24
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -78
- package/regex.generated.d.ts +0 -2
- package/regex.generated.d.ts.map +0 -1
- package/regex.generated.js +0 -5
- package/types/core.d.ts +0 -11
- package/types/core.d.ts.map +0 -1
- package/types/core.js +0 -2
- package/types/date-time.d.ts +0 -135
- package/types/date-time.d.ts.map +0 -1
- package/types/date-time.js +0 -9
- package/types/displaynames.d.ts +0 -47
- package/types/displaynames.d.ts.map +0 -1
- package/types/displaynames.js +0 -2
- package/types/list.d.ts +0 -19
- package/types/list.d.ts.map +0 -1
- package/types/list.js +0 -2
- package/types/number.d.ts +0 -147
- package/types/number.d.ts.map +0 -1
- package/types/number.js +0 -2
- package/types/plural-rules.d.ts +0 -17
- package/types/plural-rules.d.ts.map +0 -1
- package/types/plural-rules.js +0 -2
- package/types/relative-time.d.ts +0 -41
- package/types/relative-time.d.ts.map +0 -1
- package/types/relative-time.js +0 -2
- package/utils.d.ts +0 -24
- package/utils.d.ts.map +0 -1
- package/utils.js +0 -90
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var ToRawFixed_1 = require("./ToRawFixed");
|
|
4
|
-
var digit_mapping_generated_1 = require("./digit-mapping.generated");
|
|
5
|
-
var regex_generated_1 = require("../regex.generated");
|
|
6
|
-
// This is from: unicode-12.1.0/General_Category/Symbol/regex.js
|
|
7
|
-
// IE11 does not support unicode flag, otherwise this is just /\p{S}/u.
|
|
8
|
-
// /^\p{S}/u
|
|
9
|
-
var CARET_S_UNICODE_REGEX = new RegExp("^".concat(regex_generated_1.S_UNICODE_REGEX.source));
|
|
10
|
-
// /\p{S}$/u
|
|
11
|
-
var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(regex_generated_1.S_UNICODE_REGEX.source, "$"));
|
|
12
|
-
var CLDR_NUMBER_PATTERN = /[#0](?:[\.,][#0]+)*/g;
|
|
13
|
-
function formatToParts(numberResult, data, pl, options) {
|
|
14
|
-
var sign = numberResult.sign, exponent = numberResult.exponent, magnitude = numberResult.magnitude;
|
|
15
|
-
var notation = options.notation, style = options.style, numberingSystem = options.numberingSystem;
|
|
16
|
-
var defaultNumberingSystem = data.numbers.nu[0];
|
|
17
|
-
// #region Part 1: partition and interpolate the CLDR number pattern.
|
|
18
|
-
// ----------------------------------------------------------
|
|
19
|
-
var compactNumberPattern = null;
|
|
20
|
-
if (notation === 'compact' && magnitude) {
|
|
21
|
-
compactNumberPattern = getCompactDisplayPattern(numberResult, pl, data, style, options.compactDisplay, options.currencyDisplay, numberingSystem);
|
|
22
|
-
}
|
|
23
|
-
// This is used multiple times
|
|
24
|
-
var nonNameCurrencyPart;
|
|
25
|
-
if (style === 'currency' && options.currencyDisplay !== 'name') {
|
|
26
|
-
var byCurrencyDisplay = data.currencies[options.currency];
|
|
27
|
-
if (byCurrencyDisplay) {
|
|
28
|
-
switch (options.currencyDisplay) {
|
|
29
|
-
case 'code':
|
|
30
|
-
nonNameCurrencyPart = options.currency;
|
|
31
|
-
break;
|
|
32
|
-
case 'symbol':
|
|
33
|
-
nonNameCurrencyPart = byCurrencyDisplay.symbol;
|
|
34
|
-
break;
|
|
35
|
-
default:
|
|
36
|
-
nonNameCurrencyPart = byCurrencyDisplay.narrow;
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
// Fallback for unknown currency
|
|
42
|
-
nonNameCurrencyPart = options.currency;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
var numberPattern;
|
|
46
|
-
if (!compactNumberPattern) {
|
|
47
|
-
// Note: if the style is unit, or is currency and the currency display is name,
|
|
48
|
-
// its unit parts will be interpolated in part 2. So here we can fallback to decimal.
|
|
49
|
-
if (style === 'decimal' ||
|
|
50
|
-
style === 'unit' ||
|
|
51
|
-
(style === 'currency' && options.currencyDisplay === 'name')) {
|
|
52
|
-
// Shortcut for decimal
|
|
53
|
-
var decimalData = data.numbers.decimal[numberingSystem] ||
|
|
54
|
-
data.numbers.decimal[defaultNumberingSystem];
|
|
55
|
-
numberPattern = getPatternForSign(decimalData.standard, sign);
|
|
56
|
-
}
|
|
57
|
-
else if (style === 'currency') {
|
|
58
|
-
var currencyData = data.numbers.currency[numberingSystem] ||
|
|
59
|
-
data.numbers.currency[defaultNumberingSystem];
|
|
60
|
-
// We replace number pattern part with `0` for easier postprocessing.
|
|
61
|
-
numberPattern = getPatternForSign(currencyData[options.currencySign], sign);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
// percent
|
|
65
|
-
var percentPattern = data.numbers.percent[numberingSystem] ||
|
|
66
|
-
data.numbers.percent[defaultNumberingSystem];
|
|
67
|
-
numberPattern = getPatternForSign(percentPattern, sign);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
numberPattern = compactNumberPattern;
|
|
72
|
-
}
|
|
73
|
-
// Extract the decimal number pattern string. It looks like "#,##0,00", which will later be
|
|
74
|
-
// used to infer decimal group sizes.
|
|
75
|
-
var decimalNumberPattern = CLDR_NUMBER_PATTERN.exec(numberPattern)[0];
|
|
76
|
-
// Now we start to substitute patterns
|
|
77
|
-
// 1. replace strings like `0` and `#,##0.00` with `{0}`
|
|
78
|
-
// 2. unquote characters (invariant: the quoted characters does not contain the special tokens)
|
|
79
|
-
numberPattern = numberPattern
|
|
80
|
-
.replace(CLDR_NUMBER_PATTERN, '{0}')
|
|
81
|
-
.replace(/'(.)'/g, '$1');
|
|
82
|
-
// Handle currency spacing (both compact and non-compact).
|
|
83
|
-
if (style === 'currency' && options.currencyDisplay !== 'name') {
|
|
84
|
-
var currencyData = data.numbers.currency[numberingSystem] ||
|
|
85
|
-
data.numbers.currency[defaultNumberingSystem];
|
|
86
|
-
// See `currencySpacing` substitution rule in TR-35.
|
|
87
|
-
// Here we always assume the currencyMatch is "[:^S:]" and surroundingMatch is "[:digit:]".
|
|
88
|
-
//
|
|
89
|
-
// Example 1: for pattern "#,##0.00¤" with symbol "US$", we replace "¤" with the symbol,
|
|
90
|
-
// but insert an extra non-break space before the symbol, because "[:^S:]" matches "U" in
|
|
91
|
-
// "US$" and "[:digit:]" matches the latn numbering system digits.
|
|
92
|
-
//
|
|
93
|
-
// Example 2: for pattern "¤#,##0.00" with symbol "US$", there is no spacing between symbol
|
|
94
|
-
// and number, because `$` does not match "[:^S:]".
|
|
95
|
-
//
|
|
96
|
-
// Implementation note: here we do the best effort to infer the insertion.
|
|
97
|
-
// We also assume that `beforeInsertBetween` and `afterInsertBetween` will never be `;`.
|
|
98
|
-
var afterCurrency = currencyData.currencySpacing.afterInsertBetween;
|
|
99
|
-
if (afterCurrency && !S_DOLLAR_UNICODE_REGEX.test(nonNameCurrencyPart)) {
|
|
100
|
-
numberPattern = numberPattern.replace('¤{0}', "\u00A4".concat(afterCurrency, "{0}"));
|
|
101
|
-
}
|
|
102
|
-
var beforeCurrency = currencyData.currencySpacing.beforeInsertBetween;
|
|
103
|
-
if (beforeCurrency && !CARET_S_UNICODE_REGEX.test(nonNameCurrencyPart)) {
|
|
104
|
-
numberPattern = numberPattern.replace('{0}¤', "{0}".concat(beforeCurrency, "\u00A4"));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// The following tokens are special: `{0}`, `¤`, `%`, `-`, `+`, `{c:...}.
|
|
108
|
-
var numberPatternParts = numberPattern.split(/({c:[^}]+}|\{0\}|[¤%\-\+])/g);
|
|
109
|
-
var numberParts = [];
|
|
110
|
-
var symbols = data.numbers.symbols[numberingSystem] ||
|
|
111
|
-
data.numbers.symbols[defaultNumberingSystem];
|
|
112
|
-
for (var _i = 0, numberPatternParts_1 = numberPatternParts; _i < numberPatternParts_1.length; _i++) {
|
|
113
|
-
var part = numberPatternParts_1[_i];
|
|
114
|
-
if (!part) {
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
switch (part) {
|
|
118
|
-
case '{0}': {
|
|
119
|
-
// We only need to handle scientific and engineering notation here.
|
|
120
|
-
numberParts.push.apply(numberParts, paritionNumberIntoParts(symbols, numberResult, notation, exponent, numberingSystem,
|
|
121
|
-
// If compact number pattern exists, do not insert group separators.
|
|
122
|
-
!compactNumberPattern && options.useGrouping, decimalNumberPattern));
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
case '-':
|
|
126
|
-
numberParts.push({ type: 'minusSign', value: symbols.minusSign });
|
|
127
|
-
break;
|
|
128
|
-
case '+':
|
|
129
|
-
numberParts.push({ type: 'plusSign', value: symbols.plusSign });
|
|
130
|
-
break;
|
|
131
|
-
case '%':
|
|
132
|
-
numberParts.push({ type: 'percentSign', value: symbols.percentSign });
|
|
133
|
-
break;
|
|
134
|
-
case '¤':
|
|
135
|
-
// Computed above when handling currency spacing.
|
|
136
|
-
numberParts.push({ type: 'currency', value: nonNameCurrencyPart });
|
|
137
|
-
break;
|
|
138
|
-
default:
|
|
139
|
-
if (/^\{c:/.test(part)) {
|
|
140
|
-
numberParts.push({
|
|
141
|
-
type: 'compact',
|
|
142
|
-
value: part.substring(3, part.length - 1),
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
// literal
|
|
147
|
-
numberParts.push({ type: 'literal', value: part });
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// #endregion
|
|
153
|
-
// #region Part 2: interpolate unit pattern if necessary.
|
|
154
|
-
// ----------------------------------------------
|
|
155
|
-
switch (style) {
|
|
156
|
-
case 'currency': {
|
|
157
|
-
// `currencyDisplay: 'name'` has similar pattern handling as units.
|
|
158
|
-
if (options.currencyDisplay === 'name') {
|
|
159
|
-
var unitPattern = (data.numbers.currency[numberingSystem] ||
|
|
160
|
-
data.numbers.currency[defaultNumberingSystem]).unitPattern;
|
|
161
|
-
// Select plural
|
|
162
|
-
var unitName = void 0;
|
|
163
|
-
var currencyNameData = data.currencies[options.currency];
|
|
164
|
-
if (currencyNameData) {
|
|
165
|
-
unitName = selectPlural(pl, numberResult.roundedNumber * Math.pow(10, exponent), currencyNameData.displayName);
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
// Fallback for unknown currency
|
|
169
|
-
unitName = options.currency;
|
|
170
|
-
}
|
|
171
|
-
// Do {0} and {1} substitution
|
|
172
|
-
var unitPatternParts = unitPattern.split(/(\{[01]\})/g);
|
|
173
|
-
var result = [];
|
|
174
|
-
for (var _a = 0, unitPatternParts_1 = unitPatternParts; _a < unitPatternParts_1.length; _a++) {
|
|
175
|
-
var part = unitPatternParts_1[_a];
|
|
176
|
-
switch (part) {
|
|
177
|
-
case '{0}':
|
|
178
|
-
result.push.apply(result, numberParts);
|
|
179
|
-
break;
|
|
180
|
-
case '{1}':
|
|
181
|
-
result.push({ type: 'currency', value: unitName });
|
|
182
|
-
break;
|
|
183
|
-
default:
|
|
184
|
-
if (part) {
|
|
185
|
-
result.push({ type: 'literal', value: part });
|
|
186
|
-
}
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
return numberParts;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
case 'unit': {
|
|
197
|
-
var unit = options.unit, unitDisplay = options.unitDisplay;
|
|
198
|
-
var unitData = data.units.simple[unit];
|
|
199
|
-
var unitPattern = void 0;
|
|
200
|
-
if (unitData) {
|
|
201
|
-
// Simple unit pattern
|
|
202
|
-
unitPattern = selectPlural(pl, numberResult.roundedNumber * Math.pow(10, exponent), data.units.simple[unit][unitDisplay]);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
// See: http://unicode.org/reports/tr35/tr35-general.html#perUnitPatterns
|
|
206
|
-
// If cannot find unit in the simple pattern, it must be "per" compound pattern.
|
|
207
|
-
// Implementation note: we are not following TR-35 here because we need to format to parts!
|
|
208
|
-
var _b = unit.split('-per-'), numeratorUnit = _b[0], denominatorUnit = _b[1];
|
|
209
|
-
unitData = data.units.simple[numeratorUnit];
|
|
210
|
-
var numeratorUnitPattern = selectPlural(pl, numberResult.roundedNumber * Math.pow(10, exponent), data.units.simple[numeratorUnit][unitDisplay]);
|
|
211
|
-
var perUnitPattern = data.units.simple[denominatorUnit].perUnit[unitDisplay];
|
|
212
|
-
if (perUnitPattern) {
|
|
213
|
-
// perUnitPattern exists, combine it with numeratorUnitPattern
|
|
214
|
-
unitPattern = perUnitPattern.replace('{0}', numeratorUnitPattern);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
// get compoundUnit pattern (e.g. "{0} per {1}"), repalce {0} with numerator pattern and {1} with
|
|
218
|
-
// the denominator pattern in singular form.
|
|
219
|
-
var perPattern = data.units.compound.per[unitDisplay];
|
|
220
|
-
var denominatorPattern = selectPlural(pl, 1, data.units.simple[denominatorUnit][unitDisplay]);
|
|
221
|
-
unitPattern = unitPattern = perPattern
|
|
222
|
-
.replace('{0}', numeratorUnitPattern)
|
|
223
|
-
.replace('{1}', denominatorPattern.replace('{0}', ''));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
var result = [];
|
|
227
|
-
// We need spacing around "{0}" because they are not treated as "unit" parts, but "literal".
|
|
228
|
-
for (var _c = 0, _d = unitPattern.split(/(\s*\{0\}\s*)/); _c < _d.length; _c++) {
|
|
229
|
-
var part = _d[_c];
|
|
230
|
-
var interpolateMatch = /^(\s*)\{0\}(\s*)$/.exec(part);
|
|
231
|
-
if (interpolateMatch) {
|
|
232
|
-
// Space before "{0}"
|
|
233
|
-
if (interpolateMatch[1]) {
|
|
234
|
-
result.push({ type: 'literal', value: interpolateMatch[1] });
|
|
235
|
-
}
|
|
236
|
-
// "{0}" itself
|
|
237
|
-
result.push.apply(result, numberParts);
|
|
238
|
-
// Space after "{0}"
|
|
239
|
-
if (interpolateMatch[2]) {
|
|
240
|
-
result.push({ type: 'literal', value: interpolateMatch[2] });
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
else if (part) {
|
|
244
|
-
result.push({ type: 'unit', value: part });
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return result;
|
|
248
|
-
}
|
|
249
|
-
default:
|
|
250
|
-
return numberParts;
|
|
251
|
-
}
|
|
252
|
-
// #endregion
|
|
253
|
-
}
|
|
254
|
-
exports.default = formatToParts;
|
|
255
|
-
// A subset of https://tc39.es/ecma402/#sec-partitionnotationsubpattern
|
|
256
|
-
// Plus the exponent parts handling.
|
|
257
|
-
function paritionNumberIntoParts(symbols, numberResult, notation, exponent, numberingSystem, useGrouping,
|
|
258
|
-
/**
|
|
259
|
-
* This is the decimal number pattern without signs or symbols.
|
|
260
|
-
* It is used to infer the group size when `useGrouping` is true.
|
|
261
|
-
*
|
|
262
|
-
* A typical value looks like "#,##0.00" (primary group size is 3).
|
|
263
|
-
* Some locales like Hindi has secondary group size of 2 (e.g. "#,##,##0.00").
|
|
264
|
-
*/
|
|
265
|
-
decimalNumberPattern) {
|
|
266
|
-
var result = [];
|
|
267
|
-
// eslint-disable-next-line prefer-const
|
|
268
|
-
var n = numberResult.formattedString, x = numberResult.roundedNumber;
|
|
269
|
-
if (isNaN(x)) {
|
|
270
|
-
return [{ type: 'nan', value: n }];
|
|
271
|
-
}
|
|
272
|
-
else if (!isFinite(x)) {
|
|
273
|
-
return [{ type: 'infinity', value: n }];
|
|
274
|
-
}
|
|
275
|
-
var digitReplacementTable = digit_mapping_generated_1.digitMapping[numberingSystem];
|
|
276
|
-
if (digitReplacementTable) {
|
|
277
|
-
n = n.replace(/\d/g, function (digit) { return digitReplacementTable[+digit] || digit; });
|
|
278
|
-
}
|
|
279
|
-
// TODO: Else use an implementation dependent algorithm to map n to the appropriate
|
|
280
|
-
// representation of n in the given numbering system.
|
|
281
|
-
var decimalSepIndex = n.indexOf('.');
|
|
282
|
-
var integer;
|
|
283
|
-
var fraction;
|
|
284
|
-
if (decimalSepIndex > 0) {
|
|
285
|
-
integer = n.slice(0, decimalSepIndex);
|
|
286
|
-
fraction = n.slice(decimalSepIndex + 1);
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
integer = n;
|
|
290
|
-
}
|
|
291
|
-
// #region Grouping integer digits
|
|
292
|
-
// The weird compact and x >= 10000 check is to ensure consistency with Node.js and Chrome.
|
|
293
|
-
// Note that `de` does not have compact form for thousands, but Node.js does not insert grouping separator
|
|
294
|
-
// unless the rounded number is greater than 10000:
|
|
295
|
-
// NumberFormat('de', {notation: 'compact', compactDisplay: 'short'}).format(1234) //=> "1234"
|
|
296
|
-
// NumberFormat('de').format(1234) //=> "1.234"
|
|
297
|
-
if (useGrouping && (notation !== 'compact' || x >= 10000)) {
|
|
298
|
-
var groupSepSymbol = symbols.group;
|
|
299
|
-
var groups = [];
|
|
300
|
-
// > There may be two different grouping sizes: The primary grouping size used for the least
|
|
301
|
-
// > significant integer group, and the secondary grouping size used for more significant groups.
|
|
302
|
-
// > If a pattern contains multiple grouping separators, the interval between the last one and the
|
|
303
|
-
// > end of the integer defines the primary grouping size, and the interval between the last two
|
|
304
|
-
// > defines the secondary grouping size. All others are ignored.
|
|
305
|
-
var integerNumberPattern = decimalNumberPattern.split('.')[0];
|
|
306
|
-
var patternGroups = integerNumberPattern.split(',');
|
|
307
|
-
var primaryGroupingSize = 3;
|
|
308
|
-
var secondaryGroupingSize = 3;
|
|
309
|
-
if (patternGroups.length > 1) {
|
|
310
|
-
primaryGroupingSize = patternGroups[patternGroups.length - 1].length;
|
|
311
|
-
}
|
|
312
|
-
if (patternGroups.length > 2) {
|
|
313
|
-
secondaryGroupingSize = patternGroups[patternGroups.length - 2].length;
|
|
314
|
-
}
|
|
315
|
-
var i = integer.length - primaryGroupingSize;
|
|
316
|
-
if (i > 0) {
|
|
317
|
-
// Slice the least significant integer group
|
|
318
|
-
groups.push(integer.slice(i, i + primaryGroupingSize));
|
|
319
|
-
// Then iteratively push the more signicant groups
|
|
320
|
-
// TODO: handle surrogate pairs in some numbering system digits
|
|
321
|
-
for (i -= secondaryGroupingSize; i > 0; i -= secondaryGroupingSize) {
|
|
322
|
-
groups.push(integer.slice(i, i + secondaryGroupingSize));
|
|
323
|
-
}
|
|
324
|
-
groups.push(integer.slice(0, i + secondaryGroupingSize));
|
|
325
|
-
}
|
|
326
|
-
else {
|
|
327
|
-
groups.push(integer);
|
|
328
|
-
}
|
|
329
|
-
while (groups.length > 0) {
|
|
330
|
-
var integerGroup = groups.pop();
|
|
331
|
-
result.push({ type: 'integer', value: integerGroup });
|
|
332
|
-
if (groups.length > 0) {
|
|
333
|
-
result.push({ type: 'group', value: groupSepSymbol });
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
else {
|
|
338
|
-
result.push({ type: 'integer', value: integer });
|
|
339
|
-
}
|
|
340
|
-
// #endregion
|
|
341
|
-
if (fraction !== undefined) {
|
|
342
|
-
result.push({ type: 'decimal', value: symbols.decimal }, { type: 'fraction', value: fraction });
|
|
343
|
-
}
|
|
344
|
-
if ((notation === 'scientific' || notation === 'engineering') &&
|
|
345
|
-
isFinite(x)) {
|
|
346
|
-
result.push({ type: 'exponentSeparator', value: symbols.exponential });
|
|
347
|
-
if (exponent < 0) {
|
|
348
|
-
result.push({ type: 'exponentMinusSign', value: symbols.minusSign });
|
|
349
|
-
exponent = -exponent;
|
|
350
|
-
}
|
|
351
|
-
var exponentResult = (0, ToRawFixed_1.ToRawFixed)(exponent, 0, 0);
|
|
352
|
-
result.push({
|
|
353
|
-
type: 'exponentInteger',
|
|
354
|
-
value: exponentResult.formattedString,
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
return result;
|
|
358
|
-
}
|
|
359
|
-
function getPatternForSign(pattern, sign) {
|
|
360
|
-
if (pattern.indexOf(';') < 0) {
|
|
361
|
-
pattern = "".concat(pattern, ";-").concat(pattern);
|
|
362
|
-
}
|
|
363
|
-
var _a = pattern.split(';'), zeroPattern = _a[0], negativePattern = _a[1];
|
|
364
|
-
switch (sign) {
|
|
365
|
-
case 0:
|
|
366
|
-
return zeroPattern;
|
|
367
|
-
case -1:
|
|
368
|
-
return negativePattern;
|
|
369
|
-
default:
|
|
370
|
-
return negativePattern.indexOf('-') >= 0
|
|
371
|
-
? negativePattern.replace(/-/g, '+')
|
|
372
|
-
: "+".concat(zeroPattern);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
// Find the CLDR pattern for compact notation based on the magnitude of data and style.
|
|
376
|
-
//
|
|
377
|
-
// Example return value: "¤ {c:laki}000;¤{c:laki} -0" (`sw` locale):
|
|
378
|
-
// - Notice the `{c:...}` token that wraps the compact literal.
|
|
379
|
-
// - The consecutive zeros are normalized to single zero to match CLDR_NUMBER_PATTERN.
|
|
380
|
-
//
|
|
381
|
-
// Returning null means the compact display pattern cannot be found.
|
|
382
|
-
function getCompactDisplayPattern(numberResult, pl, data, style, compactDisplay, currencyDisplay, numberingSystem) {
|
|
383
|
-
var _a;
|
|
384
|
-
var roundedNumber = numberResult.roundedNumber, sign = numberResult.sign, magnitude = numberResult.magnitude;
|
|
385
|
-
var magnitudeKey = String(Math.pow(10, magnitude));
|
|
386
|
-
var defaultNumberingSystem = data.numbers.nu[0];
|
|
387
|
-
var pattern;
|
|
388
|
-
if (style === 'currency' && currencyDisplay !== 'name') {
|
|
389
|
-
var byNumberingSystem = data.numbers.currency;
|
|
390
|
-
var currencyData = byNumberingSystem[numberingSystem] ||
|
|
391
|
-
byNumberingSystem[defaultNumberingSystem];
|
|
392
|
-
// NOTE: compact notation ignores currencySign!
|
|
393
|
-
var compactPluralRules = (_a = currencyData.short) === null || _a === void 0 ? void 0 : _a[magnitudeKey];
|
|
394
|
-
if (!compactPluralRules) {
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
pattern = selectPlural(pl, roundedNumber, compactPluralRules);
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
var byNumberingSystem = data.numbers.decimal;
|
|
401
|
-
var byCompactDisplay = byNumberingSystem[numberingSystem] ||
|
|
402
|
-
byNumberingSystem[defaultNumberingSystem];
|
|
403
|
-
var compactPlaralRule = byCompactDisplay[compactDisplay][magnitudeKey];
|
|
404
|
-
if (!compactPlaralRule) {
|
|
405
|
-
return null;
|
|
406
|
-
}
|
|
407
|
-
pattern = selectPlural(pl, roundedNumber, compactPlaralRule);
|
|
408
|
-
}
|
|
409
|
-
// See https://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
|
|
410
|
-
// > If the value is precisely “0”, either explicit or defaulted, then the normal number format
|
|
411
|
-
// > pattern for that sort of object is supplied.
|
|
412
|
-
if (pattern === '0') {
|
|
413
|
-
return null;
|
|
414
|
-
}
|
|
415
|
-
pattern = getPatternForSign(pattern, sign)
|
|
416
|
-
// Extract compact literal from the pattern
|
|
417
|
-
.replace(/([^\s;\-\+\d¤]+)/g, '{c:$1}')
|
|
418
|
-
// We replace one or more zeros with a single zero so it matches `CLDR_NUMBER_PATTERN`.
|
|
419
|
-
.replace(/0+/, '0');
|
|
420
|
-
return pattern;
|
|
421
|
-
}
|
|
422
|
-
function selectPlural(pl, x, rules) {
|
|
423
|
-
return rules[pl.select(x)] || rules.other;
|
|
424
|
-
}
|
package/PartitionPattern.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PartitionPattern.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/PartitionPattern.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,OAAO,EAAE,MAAM,GACd,KAAK,CAAC;IAAC,IAAI,EAAE,CAAC,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,CAAC,CA6B7C"}
|
package/PartitionPattern.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PartitionPattern = void 0;
|
|
4
|
-
var utils_1 = require("./utils");
|
|
5
|
-
/**
|
|
6
|
-
* https://tc39.es/ecma402/#sec-partitionpattern
|
|
7
|
-
* @param pattern
|
|
8
|
-
*/
|
|
9
|
-
function PartitionPattern(pattern) {
|
|
10
|
-
var result = [];
|
|
11
|
-
var beginIndex = pattern.indexOf('{');
|
|
12
|
-
var endIndex = 0;
|
|
13
|
-
var nextIndex = 0;
|
|
14
|
-
var length = pattern.length;
|
|
15
|
-
while (beginIndex < pattern.length && beginIndex > -1) {
|
|
16
|
-
endIndex = pattern.indexOf('}', beginIndex);
|
|
17
|
-
(0, utils_1.invariant)(endIndex > beginIndex, "Invalid pattern ".concat(pattern));
|
|
18
|
-
if (beginIndex > nextIndex) {
|
|
19
|
-
result.push({
|
|
20
|
-
type: 'literal',
|
|
21
|
-
value: pattern.substring(nextIndex, beginIndex),
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
result.push({
|
|
25
|
-
type: pattern.substring(beginIndex + 1, endIndex),
|
|
26
|
-
value: undefined,
|
|
27
|
-
});
|
|
28
|
-
nextIndex = endIndex + 1;
|
|
29
|
-
beginIndex = pattern.indexOf('{', nextIndex);
|
|
30
|
-
}
|
|
31
|
-
if (nextIndex < length) {
|
|
32
|
-
result.push({
|
|
33
|
-
type: 'literal',
|
|
34
|
-
value: pattern.substring(nextIndex, length),
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
exports.PartitionPattern = PartitionPattern;
|
package/SupportedLocales.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://tc39.es/ecma402/#sec-supportedlocales
|
|
3
|
-
* @param availableLocales
|
|
4
|
-
* @param requestedLocales
|
|
5
|
-
* @param options
|
|
6
|
-
*/
|
|
7
|
-
export declare function SupportedLocales(availableLocales: Set<string>, requestedLocales: string[], options?: {
|
|
8
|
-
localeMatcher?: 'best fit' | 'lookup';
|
|
9
|
-
}): string[];
|
|
10
|
-
//# sourceMappingURL=SupportedLocales.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SupportedLocales.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/SupportedLocales.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC7B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,OAAO,CAAC,EAAE;IAAC,aAAa,CAAC,EAAE,UAAU,GAAG,QAAQ,CAAA;CAAC,GAChD,MAAM,EAAE,CAgBV"}
|
package/SupportedLocales.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SupportedLocales = void 0;
|
|
4
|
-
var _262_1 = require("./262");
|
|
5
|
-
var GetOption_1 = require("./GetOption");
|
|
6
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
7
|
-
/**
|
|
8
|
-
* https://tc39.es/ecma402/#sec-supportedlocales
|
|
9
|
-
* @param availableLocales
|
|
10
|
-
* @param requestedLocales
|
|
11
|
-
* @param options
|
|
12
|
-
*/
|
|
13
|
-
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
14
|
-
var matcher = 'best fit';
|
|
15
|
-
if (options !== undefined) {
|
|
16
|
-
options = (0, _262_1.ToObject)(options);
|
|
17
|
-
matcher = (0, GetOption_1.GetOption)(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
|
18
|
-
}
|
|
19
|
-
if (matcher === 'best fit') {
|
|
20
|
-
return (0, intl_localematcher_1.LookupSupportedLocales)(availableLocales, requestedLocales);
|
|
21
|
-
}
|
|
22
|
-
return (0, intl_localematcher_1.LookupSupportedLocales)(availableLocales, requestedLocales);
|
|
23
|
-
}
|
|
24
|
-
exports.SupportedLocales = SupportedLocales;
|
package/data.d.ts
DELETED
package/data.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/data.ts"],"names":[],"mappings":"AAAA,cAAM,sBAAuB,SAAQ,KAAK;IACjC,IAAI,SAAwB;CACpC;AAED,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,KAAK,GACP,CAAC,IAAI,sBAAsB,CAE7B"}
|
package/data.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMissingLocaleDataError = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var MissingLocaleDataError = /** @class */ (function (_super) {
|
|
6
|
-
(0, tslib_1.__extends)(MissingLocaleDataError, _super);
|
|
7
|
-
function MissingLocaleDataError() {
|
|
8
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
9
|
-
_this.type = 'MISSING_LOCALE_DATA';
|
|
10
|
-
return _this;
|
|
11
|
-
}
|
|
12
|
-
return MissingLocaleDataError;
|
|
13
|
-
}(Error));
|
|
14
|
-
function isMissingLocaleDataError(e) {
|
|
15
|
-
return e.type === 'MISSING_LOCALE_DATA';
|
|
16
|
-
}
|
|
17
|
-
exports.isMissingLocaleDataError = isMissingLocaleDataError;
|
package/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export * from './CanonicalizeLocaleList';
|
|
2
|
-
export * from './CanonicalizeTimeZoneName';
|
|
3
|
-
export * from './CoerceOptionsToObject';
|
|
4
|
-
export * from './GetNumberOption';
|
|
5
|
-
export * from './GetOption';
|
|
6
|
-
export * from './GetOptionsObject';
|
|
7
|
-
export * from './IsSanctionedSimpleUnitIdentifier';
|
|
8
|
-
export * from './IsValidTimeZoneName';
|
|
9
|
-
export * from './IsWellFormedCurrencyCode';
|
|
10
|
-
export * from './IsWellFormedUnitIdentifier';
|
|
11
|
-
export * from './NumberFormat/ComputeExponent';
|
|
12
|
-
export * from './NumberFormat/ComputeExponentForMagnitude';
|
|
13
|
-
export * from './NumberFormat/CurrencyDigits';
|
|
14
|
-
export * from './NumberFormat/FormatNumericToParts';
|
|
15
|
-
export * from './NumberFormat/FormatNumericToString';
|
|
16
|
-
export * from './NumberFormat/InitializeNumberFormat';
|
|
17
|
-
export * from './NumberFormat/PartitionNumberPattern';
|
|
18
|
-
export * from './NumberFormat/SetNumberFormatDigitOptions';
|
|
19
|
-
export * from './NumberFormat/SetNumberFormatUnitOptions';
|
|
20
|
-
export * from './NumberFormat/ToRawFixed';
|
|
21
|
-
export * from './NumberFormat/ToRawPrecision';
|
|
22
|
-
export { default as _formatToParts } from './NumberFormat/format_to_parts';
|
|
23
|
-
export * from './PartitionPattern';
|
|
24
|
-
export * from './SupportedLocales';
|
|
25
|
-
export { getInternalSlot, getMultiInternalSlots, isLiteralPart, setInternalSlot, setMultiInternalSlots, getMagnitude, defineProperty, } from './utils';
|
|
26
|
-
export type { LiteralPart } from './utils';
|
|
27
|
-
export { isMissingLocaleDataError } from './data';
|
|
28
|
-
export * from './types/relative-time';
|
|
29
|
-
export * from './types/date-time';
|
|
30
|
-
export * from './types/list';
|
|
31
|
-
export * from './types/plural-rules';
|
|
32
|
-
export * from './types/number';
|
|
33
|
-
export * from './types/displaynames';
|
|
34
|
-
export { invariant } from './utils';
|
|
35
|
-
export type { LocaleData } from './types/core';
|
|
36
|
-
export * from './262';
|
|
37
|
-
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,oCAAoC,CAAA;AAClD,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,4CAA4C,CAAA;AAC1D,cAAc,+BAA+B,CAAA;AAC7C,cAAc,qCAAqC,CAAA;AACnD,cAAc,sCAAsC,CAAA;AACpD,cAAc,uCAAuC,CAAA;AACrD,cAAc,uCAAuC,CAAA;AACrD,cAAc,4CAA4C,CAAA;AAC1D,cAAc,2CAA2C,CAAA;AACzD,cAAc,2BAA2B,CAAA;AACzC,cAAc,+BAA+B,CAAA;AAC7C,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,gCAAgC,CAAA;AACxE,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAA;AAChB,YAAY,EAAC,WAAW,EAAC,MAAM,SAAS,CAAA;AAExC,OAAO,EAAC,wBAAwB,EAAC,MAAM,QAAQ,CAAA;AAC/C,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,OAAO,EAAC,SAAS,EAAC,MAAM,SAAS,CAAA;AACjC,YAAY,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AAC5C,cAAc,OAAO,CAAA"}
|
package/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invariant = exports.isMissingLocaleDataError = exports.defineProperty = exports.getMagnitude = exports.setMultiInternalSlots = exports.setInternalSlot = exports.isLiteralPart = exports.getMultiInternalSlots = exports.getInternalSlot = exports._formatToParts = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
(0, tslib_1.__exportStar)(require("./CanonicalizeLocaleList"), exports);
|
|
6
|
-
(0, tslib_1.__exportStar)(require("./CanonicalizeTimeZoneName"), exports);
|
|
7
|
-
(0, tslib_1.__exportStar)(require("./CoerceOptionsToObject"), exports);
|
|
8
|
-
(0, tslib_1.__exportStar)(require("./GetNumberOption"), exports);
|
|
9
|
-
(0, tslib_1.__exportStar)(require("./GetOption"), exports);
|
|
10
|
-
(0, tslib_1.__exportStar)(require("./GetOptionsObject"), exports);
|
|
11
|
-
(0, tslib_1.__exportStar)(require("./IsSanctionedSimpleUnitIdentifier"), exports);
|
|
12
|
-
(0, tslib_1.__exportStar)(require("./IsValidTimeZoneName"), exports);
|
|
13
|
-
(0, tslib_1.__exportStar)(require("./IsWellFormedCurrencyCode"), exports);
|
|
14
|
-
(0, tslib_1.__exportStar)(require("./IsWellFormedUnitIdentifier"), exports);
|
|
15
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/ComputeExponent"), exports);
|
|
16
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/ComputeExponentForMagnitude"), exports);
|
|
17
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/CurrencyDigits"), exports);
|
|
18
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/FormatNumericToParts"), exports);
|
|
19
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/FormatNumericToString"), exports);
|
|
20
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/InitializeNumberFormat"), exports);
|
|
21
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/PartitionNumberPattern"), exports);
|
|
22
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/SetNumberFormatDigitOptions"), exports);
|
|
23
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/SetNumberFormatUnitOptions"), exports);
|
|
24
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/ToRawFixed"), exports);
|
|
25
|
-
(0, tslib_1.__exportStar)(require("./NumberFormat/ToRawPrecision"), exports);
|
|
26
|
-
var format_to_parts_1 = require("./NumberFormat/format_to_parts");
|
|
27
|
-
Object.defineProperty(exports, "_formatToParts", { enumerable: true, get: function () { return (0, tslib_1.__importDefault)(format_to_parts_1).default; } });
|
|
28
|
-
(0, tslib_1.__exportStar)(require("./PartitionPattern"), exports);
|
|
29
|
-
(0, tslib_1.__exportStar)(require("./SupportedLocales"), exports);
|
|
30
|
-
var utils_1 = require("./utils");
|
|
31
|
-
Object.defineProperty(exports, "getInternalSlot", { enumerable: true, get: function () { return utils_1.getInternalSlot; } });
|
|
32
|
-
Object.defineProperty(exports, "getMultiInternalSlots", { enumerable: true, get: function () { return utils_1.getMultiInternalSlots; } });
|
|
33
|
-
Object.defineProperty(exports, "isLiteralPart", { enumerable: true, get: function () { return utils_1.isLiteralPart; } });
|
|
34
|
-
Object.defineProperty(exports, "setInternalSlot", { enumerable: true, get: function () { return utils_1.setInternalSlot; } });
|
|
35
|
-
Object.defineProperty(exports, "setMultiInternalSlots", { enumerable: true, get: function () { return utils_1.setMultiInternalSlots; } });
|
|
36
|
-
Object.defineProperty(exports, "getMagnitude", { enumerable: true, get: function () { return utils_1.getMagnitude; } });
|
|
37
|
-
Object.defineProperty(exports, "defineProperty", { enumerable: true, get: function () { return utils_1.defineProperty; } });
|
|
38
|
-
var data_1 = require("./data");
|
|
39
|
-
Object.defineProperty(exports, "isMissingLocaleDataError", { enumerable: true, get: function () { return data_1.isMissingLocaleDataError; } });
|
|
40
|
-
(0, tslib_1.__exportStar)(require("./types/relative-time"), exports);
|
|
41
|
-
(0, tslib_1.__exportStar)(require("./types/date-time"), exports);
|
|
42
|
-
(0, tslib_1.__exportStar)(require("./types/list"), exports);
|
|
43
|
-
(0, tslib_1.__exportStar)(require("./types/plural-rules"), exports);
|
|
44
|
-
(0, tslib_1.__exportStar)(require("./types/number"), exports);
|
|
45
|
-
(0, tslib_1.__exportStar)(require("./types/displaynames"), exports);
|
|
46
|
-
var utils_2 = require("./utils");
|
|
47
|
-
Object.defineProperty(exports, "invariant", { enumerable: true, get: function () { return utils_2.invariant; } });
|
|
48
|
-
(0, tslib_1.__exportStar)(require("./262"), exports);
|