@formatjs/ecma402-abstract 1.11.6 → 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,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsSanctionedSimpleUnitIdentifier = exports.SIMPLE_UNITS = exports.removeUnitNamespace = exports.SANCTIONED_UNITS = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
|
|
6
|
-
*/
|
|
7
|
-
exports.SANCTIONED_UNITS = [
|
|
8
|
-
'angle-degree',
|
|
9
|
-
'area-acre',
|
|
10
|
-
'area-hectare',
|
|
11
|
-
'concentr-percent',
|
|
12
|
-
'digital-bit',
|
|
13
|
-
'digital-byte',
|
|
14
|
-
'digital-gigabit',
|
|
15
|
-
'digital-gigabyte',
|
|
16
|
-
'digital-kilobit',
|
|
17
|
-
'digital-kilobyte',
|
|
18
|
-
'digital-megabit',
|
|
19
|
-
'digital-megabyte',
|
|
20
|
-
'digital-petabyte',
|
|
21
|
-
'digital-terabit',
|
|
22
|
-
'digital-terabyte',
|
|
23
|
-
'duration-day',
|
|
24
|
-
'duration-hour',
|
|
25
|
-
'duration-millisecond',
|
|
26
|
-
'duration-minute',
|
|
27
|
-
'duration-month',
|
|
28
|
-
'duration-second',
|
|
29
|
-
'duration-week',
|
|
30
|
-
'duration-year',
|
|
31
|
-
'length-centimeter',
|
|
32
|
-
'length-foot',
|
|
33
|
-
'length-inch',
|
|
34
|
-
'length-kilometer',
|
|
35
|
-
'length-meter',
|
|
36
|
-
'length-mile-scandinavian',
|
|
37
|
-
'length-mile',
|
|
38
|
-
'length-millimeter',
|
|
39
|
-
'length-yard',
|
|
40
|
-
'mass-gram',
|
|
41
|
-
'mass-kilogram',
|
|
42
|
-
'mass-ounce',
|
|
43
|
-
'mass-pound',
|
|
44
|
-
'mass-stone',
|
|
45
|
-
'temperature-celsius',
|
|
46
|
-
'temperature-fahrenheit',
|
|
47
|
-
'volume-fluid-ounce',
|
|
48
|
-
'volume-gallon',
|
|
49
|
-
'volume-liter',
|
|
50
|
-
'volume-milliliter',
|
|
51
|
-
];
|
|
52
|
-
// In CLDR, the unit name always follows the form `namespace-unit` pattern.
|
|
53
|
-
// For example: `digital-bit` instead of `bit`. This function removes the namespace prefix.
|
|
54
|
-
function removeUnitNamespace(unit) {
|
|
55
|
-
return unit.slice(unit.indexOf('-') + 1);
|
|
56
|
-
}
|
|
57
|
-
exports.removeUnitNamespace = removeUnitNamespace;
|
|
58
|
-
/**
|
|
59
|
-
* https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
|
|
60
|
-
*/
|
|
61
|
-
exports.SIMPLE_UNITS = exports.SANCTIONED_UNITS.map(removeUnitNamespace);
|
|
62
|
-
/**
|
|
63
|
-
* https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
|
|
64
|
-
*/
|
|
65
|
-
function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
|
|
66
|
-
return exports.SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
|
|
67
|
-
}
|
|
68
|
-
exports.IsSanctionedSimpleUnitIdentifier = IsSanctionedSimpleUnitIdentifier;
|
package/IsValidTimeZoneName.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://tc39.es/ecma402/#sec-isvalidtimezonename
|
|
3
|
-
* @param tz
|
|
4
|
-
* @param implDetails implementation details
|
|
5
|
-
*/
|
|
6
|
-
export declare function IsValidTimeZoneName(tz: string, { tzData, uppercaseLinks, }: {
|
|
7
|
-
tzData: Record<string, unknown>;
|
|
8
|
-
uppercaseLinks: Record<string, string>;
|
|
9
|
-
}): boolean;
|
|
10
|
-
//# sourceMappingURL=IsValidTimeZoneName.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IsValidTimeZoneName.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/IsValidTimeZoneName.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,EACV,EACE,MAAM,EACN,cAAc,GACf,EAAE;IACD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC/B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACvC,GACA,OAAO,CAYT"}
|
package/IsValidTimeZoneName.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsValidTimeZoneName = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* https://tc39.es/ecma402/#sec-isvalidtimezonename
|
|
6
|
-
* @param tz
|
|
7
|
-
* @param implDetails implementation details
|
|
8
|
-
*/
|
|
9
|
-
function IsValidTimeZoneName(tz, _a) {
|
|
10
|
-
var tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
|
|
11
|
-
var uppercasedTz = tz.toUpperCase();
|
|
12
|
-
var zoneNames = new Set();
|
|
13
|
-
var linkNames = new Set();
|
|
14
|
-
Object.keys(tzData)
|
|
15
|
-
.map(function (z) { return z.toUpperCase(); })
|
|
16
|
-
.forEach(function (z) { return zoneNames.add(z); });
|
|
17
|
-
Object.keys(uppercaseLinks).forEach(function (linkName) {
|
|
18
|
-
linkNames.add(linkName.toUpperCase());
|
|
19
|
-
zoneNames.add(uppercaseLinks[linkName].toUpperCase());
|
|
20
|
-
});
|
|
21
|
-
return zoneNames.has(uppercasedTz) || linkNames.has(uppercasedTz);
|
|
22
|
-
}
|
|
23
|
-
exports.IsValidTimeZoneName = IsValidTimeZoneName;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IsWellFormedCurrencyCode.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/IsWellFormedCurrencyCode.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CASlE"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsWellFormedCurrencyCode = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
|
|
6
|
-
* @param str string to convert
|
|
7
|
-
*/
|
|
8
|
-
function toUpperCase(str) {
|
|
9
|
-
return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
|
|
10
|
-
}
|
|
11
|
-
var NOT_A_Z_REGEX = /[^A-Z]/;
|
|
12
|
-
/**
|
|
13
|
-
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
|
|
14
|
-
*/
|
|
15
|
-
function IsWellFormedCurrencyCode(currency) {
|
|
16
|
-
currency = toUpperCase(currency);
|
|
17
|
-
if (currency.length !== 3) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
if (NOT_A_Z_REGEX.test(currency)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
exports.IsWellFormedCurrencyCode = IsWellFormedCurrencyCode;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IsWellFormedUnitIdentifier.d.ts","sourceRoot":"","sources":["../../../../../packages/ecma402-abstract/IsWellFormedUnitIdentifier.ts"],"names":[],"mappings":"AAUA;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,WAiBtD"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IsWellFormedUnitIdentifier = void 0;
|
|
4
|
-
var IsSanctionedSimpleUnitIdentifier_1 = require("./IsSanctionedSimpleUnitIdentifier");
|
|
5
|
-
/**
|
|
6
|
-
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
|
|
7
|
-
* @param str string to convert
|
|
8
|
-
*/
|
|
9
|
-
function toLowerCase(str) {
|
|
10
|
-
return str.replace(/([A-Z])/g, function (_, c) { return c.toLowerCase(); });
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* https://tc39.es/ecma402/#sec-iswellformedunitidentifier
|
|
14
|
-
* @param unit
|
|
15
|
-
*/
|
|
16
|
-
function IsWellFormedUnitIdentifier(unit) {
|
|
17
|
-
unit = toLowerCase(unit);
|
|
18
|
-
if ((0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(unit)) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
var units = unit.split('-per-');
|
|
22
|
-
if (units.length !== 2) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
var numerator = units[0], denominator = units[1];
|
|
26
|
-
if (!(0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(numerator) ||
|
|
27
|
-
!(0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(denominator)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
exports.IsWellFormedUnitIdentifier = IsWellFormedUnitIdentifier;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { NumberFormatInternal } from '../types/number';
|
|
2
|
-
/**
|
|
3
|
-
* The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
|
|
4
|
-
* according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
|
|
5
|
-
* requiring a different exponent.
|
|
6
|
-
*
|
|
7
|
-
* NOT IN SPEC: it returns [exponent, magnitude].
|
|
8
|
-
*/
|
|
9
|
-
export declare function ComputeExponent(numberFormat: Intl.NumberFormat, x: number, { getInternalSlots, }: {
|
|
10
|
-
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
11
|
-
}): [number, number];
|
|
12
|
-
//# sourceMappingURL=ComputeExponent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComputeExponent.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/ComputeExponent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAEpD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAAC,GACjE,CAAC,MAAM,EAAE,MAAM,CAAC,CA8BlB"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComputeExponent = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
var ComputeExponentForMagnitude_1 = require("./ComputeExponentForMagnitude");
|
|
6
|
-
var FormatNumericToString_1 = require("./FormatNumericToString");
|
|
7
|
-
/**
|
|
8
|
-
* The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
|
|
9
|
-
* according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
|
|
10
|
-
* requiring a different exponent.
|
|
11
|
-
*
|
|
12
|
-
* NOT IN SPEC: it returns [exponent, magnitude].
|
|
13
|
-
*/
|
|
14
|
-
function ComputeExponent(numberFormat, x, _a) {
|
|
15
|
-
var getInternalSlots = _a.getInternalSlots;
|
|
16
|
-
if (x === 0) {
|
|
17
|
-
return [0, 0];
|
|
18
|
-
}
|
|
19
|
-
if (x < 0) {
|
|
20
|
-
x = -x;
|
|
21
|
-
}
|
|
22
|
-
var magnitude = (0, utils_1.getMagnitude)(x);
|
|
23
|
-
var exponent = (0, ComputeExponentForMagnitude_1.ComputeExponentForMagnitude)(numberFormat, magnitude, {
|
|
24
|
-
getInternalSlots: getInternalSlots,
|
|
25
|
-
});
|
|
26
|
-
// Preserve more precision by doing multiplication when exponent is negative.
|
|
27
|
-
x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
|
|
28
|
-
var formatNumberResult = (0, FormatNumericToString_1.FormatNumericToString)(getInternalSlots(numberFormat), x);
|
|
29
|
-
if (formatNumberResult.roundedNumber === 0) {
|
|
30
|
-
return [exponent, magnitude];
|
|
31
|
-
}
|
|
32
|
-
var newMagnitude = (0, utils_1.getMagnitude)(formatNumberResult.roundedNumber);
|
|
33
|
-
if (newMagnitude === magnitude - exponent) {
|
|
34
|
-
return [exponent, magnitude];
|
|
35
|
-
}
|
|
36
|
-
return [
|
|
37
|
-
(0, ComputeExponentForMagnitude_1.ComputeExponentForMagnitude)(numberFormat, magnitude + 1, {
|
|
38
|
-
getInternalSlots: getInternalSlots,
|
|
39
|
-
}),
|
|
40
|
-
magnitude + 1,
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
exports.ComputeExponent = ComputeExponent;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { NumberFormatInternal } from '../types/number';
|
|
2
|
-
/**
|
|
3
|
-
* The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
|
|
4
|
-
* number of the given magnitude (power of ten of the most significant digit) according to the
|
|
5
|
-
* locale and the desired notation (scientific, engineering, or compact).
|
|
6
|
-
*/
|
|
7
|
-
export declare function ComputeExponentForMagnitude(numberFormat: Intl.NumberFormat, magnitude: number, { getInternalSlots, }: {
|
|
8
|
-
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
9
|
-
}): number;
|
|
10
|
-
//# sourceMappingURL=ComputeExponentForMagnitude.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ComputeExponentForMagnitude.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAmB,MAAM,iBAAiB,CAAA;AAEtE;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,SAAS,EAAE,MAAM,EACjB,EACE,gBAAgB,GACjB,EAAE;IAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAAC,GACjE,MAAM,CAyDR"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComputeExponentForMagnitude = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
|
|
6
|
-
* number of the given magnitude (power of ten of the most significant digit) according to the
|
|
7
|
-
* locale and the desired notation (scientific, engineering, or compact).
|
|
8
|
-
*/
|
|
9
|
-
function ComputeExponentForMagnitude(numberFormat, magnitude, _a) {
|
|
10
|
-
var getInternalSlots = _a.getInternalSlots;
|
|
11
|
-
var internalSlots = getInternalSlots(numberFormat);
|
|
12
|
-
var notation = internalSlots.notation, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
|
|
13
|
-
switch (notation) {
|
|
14
|
-
case 'standard':
|
|
15
|
-
return 0;
|
|
16
|
-
case 'scientific':
|
|
17
|
-
return magnitude;
|
|
18
|
-
case 'engineering':
|
|
19
|
-
return Math.floor(magnitude / 3) * 3;
|
|
20
|
-
default: {
|
|
21
|
-
// Let exponent be an implementation- and locale-dependent (ILD) integer by which to scale a
|
|
22
|
-
// number of the given magnitude in compact notation for the current locale.
|
|
23
|
-
var compactDisplay = internalSlots.compactDisplay, style = internalSlots.style, currencyDisplay = internalSlots.currencyDisplay;
|
|
24
|
-
var thresholdMap = void 0;
|
|
25
|
-
if (style === 'currency' && currencyDisplay !== 'name') {
|
|
26
|
-
var currency = dataLocaleData.numbers.currency[numberingSystem] ||
|
|
27
|
-
dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]];
|
|
28
|
-
thresholdMap = currency.short;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
var decimal = dataLocaleData.numbers.decimal[numberingSystem] ||
|
|
32
|
-
dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
|
|
33
|
-
thresholdMap = compactDisplay === 'long' ? decimal.long : decimal.short;
|
|
34
|
-
}
|
|
35
|
-
if (!thresholdMap) {
|
|
36
|
-
return 0;
|
|
37
|
-
}
|
|
38
|
-
var num = String(Math.pow(10, magnitude));
|
|
39
|
-
var thresholds = Object.keys(thresholdMap); // TODO: this can be pre-processed
|
|
40
|
-
if (num < thresholds[0]) {
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
if (num > thresholds[thresholds.length - 1]) {
|
|
44
|
-
return thresholds[thresholds.length - 1].length - 1;
|
|
45
|
-
}
|
|
46
|
-
var i = thresholds.indexOf(num);
|
|
47
|
-
if (i === -1) {
|
|
48
|
-
return 0;
|
|
49
|
-
}
|
|
50
|
-
// See https://unicode.org/reports/tr35/tr35-numbers.html#Compact_Number_Formats
|
|
51
|
-
// Special handling if the pattern is precisely `0`.
|
|
52
|
-
var magnitudeKey = thresholds[i];
|
|
53
|
-
// TODO: do we need to handle plural here?
|
|
54
|
-
var compactPattern = thresholdMap[magnitudeKey].other;
|
|
55
|
-
if (compactPattern === '0') {
|
|
56
|
-
return 0;
|
|
57
|
-
}
|
|
58
|
-
// Example: in zh-TW, `10000000` maps to `0000萬`. So we need to return 8 - 4 = 4 here.
|
|
59
|
-
return (magnitudeKey.length -
|
|
60
|
-
thresholdMap[magnitudeKey].other.match(/0+/)[0].length);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.ComputeExponentForMagnitude = ComputeExponentForMagnitude;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyDigits.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/CurrencyDigits.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,MAAM,EACT,EAAC,kBAAkB,EAAC,EAAE;IAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAC,GACjE,MAAM,CAIR"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CurrencyDigits = void 0;
|
|
4
|
-
var _262_1 = require("../262");
|
|
5
|
-
/**
|
|
6
|
-
* https://tc39.es/ecma402/#sec-currencydigits
|
|
7
|
-
*/
|
|
8
|
-
function CurrencyDigits(c, _a) {
|
|
9
|
-
var currencyDigitsData = _a.currencyDigitsData;
|
|
10
|
-
return (0, _262_1.HasOwnProperty)(currencyDigitsData, c)
|
|
11
|
-
? currencyDigitsData[c]
|
|
12
|
-
: 2;
|
|
13
|
-
}
|
|
14
|
-
exports.CurrencyDigits = CurrencyDigits;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { NumberFormatInternal, NumberFormatPart } from '../types/number';
|
|
2
|
-
export declare function FormatNumericToParts(nf: Intl.NumberFormat, x: number, implDetails: {
|
|
3
|
-
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
4
|
-
}): NumberFormatPart[];
|
|
5
|
-
//# sourceMappingURL=FormatNumericToParts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormatNumericToParts.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/FormatNumericToParts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,oBAAoB,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAA;AAEtE,wBAAgB,oBAAoB,CAClC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,CAAC,EAAE,MAAM,EACT,WAAW,EAAE;IACX,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,GACA,gBAAgB,EAAE,CAWpB"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormatNumericToParts = void 0;
|
|
4
|
-
var PartitionNumberPattern_1 = require("./PartitionNumberPattern");
|
|
5
|
-
var _262_1 = require("../262");
|
|
6
|
-
function FormatNumericToParts(nf, x, implDetails) {
|
|
7
|
-
var parts = (0, PartitionNumberPattern_1.PartitionNumberPattern)(nf, x, implDetails);
|
|
8
|
-
var result = (0, _262_1.ArrayCreate)(0);
|
|
9
|
-
for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
|
|
10
|
-
var part = parts_1[_i];
|
|
11
|
-
result.push({
|
|
12
|
-
type: part.type,
|
|
13
|
-
value: part.value,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
exports.FormatNumericToParts = FormatNumericToParts;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { NumberFormatDigitInternalSlots } from '../types/number';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/ecma402/#sec-formatnumberstring
|
|
4
|
-
*/
|
|
5
|
-
export declare function FormatNumericToString(intlObject: Pick<NumberFormatDigitInternalSlots, 'roundingType' | 'minimumSignificantDigits' | 'maximumSignificantDigits' | 'minimumIntegerDigits' | 'minimumFractionDigits' | 'maximumFractionDigits'>, x: number): {
|
|
6
|
-
roundedNumber: number;
|
|
7
|
-
formattedString: string;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=FormatNumericToString.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FormatNumericToString.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/FormatNumericToString.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,8BAA8B,EAE/B,MAAM,iBAAiB,CAAA;AAGxB;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,IAAI,CACd,8BAA8B,EAC5B,cAAc,GACd,0BAA0B,GAC1B,0BAA0B,GAC1B,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAC1B,EACD,CAAC,EAAE,MAAM;;;EAgDV"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FormatNumericToString = void 0;
|
|
4
|
-
var _262_1 = require("../262");
|
|
5
|
-
var ToRawPrecision_1 = require("./ToRawPrecision");
|
|
6
|
-
var utils_1 = require("../utils");
|
|
7
|
-
var ToRawFixed_1 = require("./ToRawFixed");
|
|
8
|
-
/**
|
|
9
|
-
* https://tc39.es/ecma402/#sec-formatnumberstring
|
|
10
|
-
*/
|
|
11
|
-
function FormatNumericToString(intlObject, x) {
|
|
12
|
-
var isNegative = x < 0 || (0, _262_1.SameValue)(x, -0);
|
|
13
|
-
if (isNegative) {
|
|
14
|
-
x = -x;
|
|
15
|
-
}
|
|
16
|
-
var result;
|
|
17
|
-
var rourndingType = intlObject.roundingType;
|
|
18
|
-
switch (rourndingType) {
|
|
19
|
-
case 'significantDigits':
|
|
20
|
-
result = (0, ToRawPrecision_1.ToRawPrecision)(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits);
|
|
21
|
-
break;
|
|
22
|
-
case 'fractionDigits':
|
|
23
|
-
result = (0, ToRawFixed_1.ToRawFixed)(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits);
|
|
24
|
-
break;
|
|
25
|
-
default:
|
|
26
|
-
result = (0, ToRawPrecision_1.ToRawPrecision)(x, 1, 2);
|
|
27
|
-
if (result.integerDigitsCount > 1) {
|
|
28
|
-
result = (0, ToRawFixed_1.ToRawFixed)(x, 0, 0);
|
|
29
|
-
}
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
x = result.roundedNumber;
|
|
33
|
-
var string = result.formattedString;
|
|
34
|
-
var int = result.integerDigitsCount;
|
|
35
|
-
var minInteger = intlObject.minimumIntegerDigits;
|
|
36
|
-
if (int < minInteger) {
|
|
37
|
-
var forwardZeros = (0, utils_1.repeat)('0', minInteger - int);
|
|
38
|
-
string = forwardZeros + string;
|
|
39
|
-
}
|
|
40
|
-
if (isNegative) {
|
|
41
|
-
x = -x;
|
|
42
|
-
}
|
|
43
|
-
return { roundedNumber: x, formattedString: string };
|
|
44
|
-
}
|
|
45
|
-
exports.FormatNumericToString = FormatNumericToString;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NumberFormatInternal, NumberFormatOptions, NumberFormatLocaleInternalData } from '../types/number';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/ecma402/#sec-initializenumberformat
|
|
4
|
-
*/
|
|
5
|
-
export declare function InitializeNumberFormat(nf: Intl.NumberFormat, locales: string | ReadonlyArray<string> | undefined, opts: NumberFormatOptions | undefined, { getInternalSlots, localeData, availableLocales, numberingSystemNames, getDefaultLocale, currencyDigitsData, }: {
|
|
6
|
-
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
7
|
-
localeData: Record<string, NumberFormatLocaleInternalData | undefined>;
|
|
8
|
-
availableLocales: Set<string>;
|
|
9
|
-
numberingSystemNames: ReadonlyArray<string>;
|
|
10
|
-
getDefaultLocale(): string;
|
|
11
|
-
currencyDigitsData: Record<string, number>;
|
|
12
|
-
}): Intl.NumberFormat;
|
|
13
|
-
//# sourceMappingURL=InitializeNumberFormat.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InitializeNumberFormat.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/InitializeNumberFormat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAUxB;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,EAAE,EAAE,IAAI,CAAC,YAAY,EACrB,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,EACnD,IAAI,EAAE,mBAAmB,GAAG,SAAS,EACrC,EACE,gBAAgB,EAChB,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,gBAAgB,EAChB,kBAAkB,GACnB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;IAC7D,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,GAAG,SAAS,CAAC,CAAA;IACtE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IAC7B,oBAAoB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IAC3C,gBAAgB,IAAI,MAAM,CAAA;IAC1B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC3C,qBA+GF"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InitializeNumberFormat = void 0;
|
|
4
|
-
var CanonicalizeLocaleList_1 = require("../CanonicalizeLocaleList");
|
|
5
|
-
var GetOption_1 = require("../GetOption");
|
|
6
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
7
|
-
var SetNumberFormatUnitOptions_1 = require("./SetNumberFormatUnitOptions");
|
|
8
|
-
var CurrencyDigits_1 = require("./CurrencyDigits");
|
|
9
|
-
var SetNumberFormatDigitOptions_1 = require("./SetNumberFormatDigitOptions");
|
|
10
|
-
var utils_1 = require("../utils");
|
|
11
|
-
var CoerceOptionsToObject_1 = require("../CoerceOptionsToObject");
|
|
12
|
-
/**
|
|
13
|
-
* https://tc39.es/ecma402/#sec-initializenumberformat
|
|
14
|
-
*/
|
|
15
|
-
function InitializeNumberFormat(nf, locales, opts, _a) {
|
|
16
|
-
var getInternalSlots = _a.getInternalSlots, localeData = _a.localeData, availableLocales = _a.availableLocales, numberingSystemNames = _a.numberingSystemNames, getDefaultLocale = _a.getDefaultLocale, currencyDigitsData = _a.currencyDigitsData;
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
var requestedLocales = (0, CanonicalizeLocaleList_1.CanonicalizeLocaleList)(locales);
|
|
19
|
-
var options = (0, CoerceOptionsToObject_1.CoerceOptionsToObject)(opts);
|
|
20
|
-
var opt = Object.create(null);
|
|
21
|
-
var matcher = (0, GetOption_1.GetOption)(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
|
22
|
-
opt.localeMatcher = matcher;
|
|
23
|
-
var numberingSystem = (0, GetOption_1.GetOption)(options, 'numberingSystem', 'string', undefined, undefined);
|
|
24
|
-
if (numberingSystem !== undefined &&
|
|
25
|
-
numberingSystemNames.indexOf(numberingSystem) < 0) {
|
|
26
|
-
// 8.a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal,
|
|
27
|
-
// throw a RangeError exception.
|
|
28
|
-
throw RangeError("Invalid numberingSystems: ".concat(numberingSystem));
|
|
29
|
-
}
|
|
30
|
-
opt.nu = numberingSystem;
|
|
31
|
-
var r = (0, intl_localematcher_1.ResolveLocale)(availableLocales, requestedLocales, opt,
|
|
32
|
-
// [[RelevantExtensionKeys]] slot, which is a constant
|
|
33
|
-
['nu'], localeData, getDefaultLocale);
|
|
34
|
-
var dataLocaleData = localeData[r.dataLocale];
|
|
35
|
-
(0, utils_1.invariant)(!!dataLocaleData, "Missing locale data for ".concat(r.dataLocale));
|
|
36
|
-
var internalSlots = getInternalSlots(nf);
|
|
37
|
-
internalSlots.locale = r.locale;
|
|
38
|
-
internalSlots.dataLocale = r.dataLocale;
|
|
39
|
-
internalSlots.numberingSystem = r.nu;
|
|
40
|
-
internalSlots.dataLocaleData = dataLocaleData;
|
|
41
|
-
(0, SetNumberFormatUnitOptions_1.SetNumberFormatUnitOptions)(nf, options, { getInternalSlots: getInternalSlots });
|
|
42
|
-
var style = internalSlots.style;
|
|
43
|
-
var mnfdDefault;
|
|
44
|
-
var mxfdDefault;
|
|
45
|
-
if (style === 'currency') {
|
|
46
|
-
var currency = internalSlots.currency;
|
|
47
|
-
var cDigits = (0, CurrencyDigits_1.CurrencyDigits)(currency, { currencyDigitsData: currencyDigitsData });
|
|
48
|
-
mnfdDefault = cDigits;
|
|
49
|
-
mxfdDefault = cDigits;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
mnfdDefault = 0;
|
|
53
|
-
mxfdDefault = style === 'percent' ? 0 : 3;
|
|
54
|
-
}
|
|
55
|
-
var notation = (0, GetOption_1.GetOption)(options, 'notation', 'string', ['standard', 'scientific', 'engineering', 'compact'], 'standard');
|
|
56
|
-
internalSlots.notation = notation;
|
|
57
|
-
(0, SetNumberFormatDigitOptions_1.SetNumberFormatDigitOptions)(internalSlots, options, mnfdDefault, mxfdDefault, notation);
|
|
58
|
-
var compactDisplay = (0, GetOption_1.GetOption)(options, 'compactDisplay', 'string', ['short', 'long'], 'short');
|
|
59
|
-
if (notation === 'compact') {
|
|
60
|
-
internalSlots.compactDisplay = compactDisplay;
|
|
61
|
-
}
|
|
62
|
-
var useGrouping = (0, GetOption_1.GetOption)(options, 'useGrouping', 'boolean', undefined, true);
|
|
63
|
-
internalSlots.useGrouping = useGrouping;
|
|
64
|
-
var signDisplay = (0, GetOption_1.GetOption)(options, 'signDisplay', 'string', ['auto', 'never', 'always', 'exceptZero'], 'auto');
|
|
65
|
-
internalSlots.signDisplay = signDisplay;
|
|
66
|
-
return nf;
|
|
67
|
-
}
|
|
68
|
-
exports.InitializeNumberFormat = InitializeNumberFormat;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { NumberFormatInternal } from '../types/number';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/ecma402/#sec-formatnumberstring
|
|
4
|
-
*/
|
|
5
|
-
export declare function PartitionNumberPattern(numberFormat: Intl.NumberFormat, x: number, { getInternalSlots, }: {
|
|
6
|
-
getInternalSlots(nf: Intl.NumberFormat): NumberFormatInternal;
|
|
7
|
-
}): import("../types/number").NumberFormatPart[];
|
|
8
|
-
//# sourceMappingURL=PartitionNumberPattern.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PartitionNumberPattern.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/PartitionNumberPattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAA;AAMpD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,IAAI,CAAC,YAAY,EAC/B,CAAC,EAAE,MAAM,EACT,EACE,gBAAgB,GACjB,EAAE;IACD,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,GAAG,oBAAoB,CAAA;CAC9D,gDAqEF"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PartitionNumberPattern = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var FormatNumericToString_1 = require("./FormatNumericToString");
|
|
6
|
-
var _262_1 = require("../262");
|
|
7
|
-
var ComputeExponent_1 = require("./ComputeExponent");
|
|
8
|
-
var format_to_parts_1 = (0, tslib_1.__importDefault)(require("./format_to_parts"));
|
|
9
|
-
/**
|
|
10
|
-
* https://tc39.es/ecma402/#sec-formatnumberstring
|
|
11
|
-
*/
|
|
12
|
-
function PartitionNumberPattern(numberFormat, x, _a) {
|
|
13
|
-
var _b;
|
|
14
|
-
var getInternalSlots = _a.getInternalSlots;
|
|
15
|
-
var internalSlots = getInternalSlots(numberFormat);
|
|
16
|
-
var pl = internalSlots.pl, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
|
|
17
|
-
var symbols = dataLocaleData.numbers.symbols[numberingSystem] ||
|
|
18
|
-
dataLocaleData.numbers.symbols[dataLocaleData.numbers.nu[0]];
|
|
19
|
-
var magnitude = 0;
|
|
20
|
-
var exponent = 0;
|
|
21
|
-
var n;
|
|
22
|
-
if (isNaN(x)) {
|
|
23
|
-
n = symbols.nan;
|
|
24
|
-
}
|
|
25
|
-
else if (!isFinite(x)) {
|
|
26
|
-
n = symbols.infinity;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
if (internalSlots.style === 'percent') {
|
|
30
|
-
x *= 100;
|
|
31
|
-
}
|
|
32
|
-
;
|
|
33
|
-
_b = (0, ComputeExponent_1.ComputeExponent)(numberFormat, x, {
|
|
34
|
-
getInternalSlots: getInternalSlots,
|
|
35
|
-
}), exponent = _b[0], magnitude = _b[1];
|
|
36
|
-
// Preserve more precision by doing multiplication when exponent is negative.
|
|
37
|
-
x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
|
|
38
|
-
var formatNumberResult = (0, FormatNumericToString_1.FormatNumericToString)(internalSlots, x);
|
|
39
|
-
n = formatNumberResult.formattedString;
|
|
40
|
-
x = formatNumberResult.roundedNumber;
|
|
41
|
-
}
|
|
42
|
-
// Based on https://tc39.es/ecma402/#sec-getnumberformatpattern
|
|
43
|
-
// We need to do this before `x` is rounded.
|
|
44
|
-
var sign;
|
|
45
|
-
var signDisplay = internalSlots.signDisplay;
|
|
46
|
-
switch (signDisplay) {
|
|
47
|
-
case 'never':
|
|
48
|
-
sign = 0;
|
|
49
|
-
break;
|
|
50
|
-
case 'auto':
|
|
51
|
-
if ((0, _262_1.SameValue)(x, 0) || x > 0 || isNaN(x)) {
|
|
52
|
-
sign = 0;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
sign = -1;
|
|
56
|
-
}
|
|
57
|
-
break;
|
|
58
|
-
case 'always':
|
|
59
|
-
if ((0, _262_1.SameValue)(x, 0) || x > 0 || isNaN(x)) {
|
|
60
|
-
sign = 1;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
sign = -1;
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
// x === 0 -> x is 0 or x is -0
|
|
68
|
-
if (x === 0 || isNaN(x)) {
|
|
69
|
-
sign = 0;
|
|
70
|
-
}
|
|
71
|
-
else if (x > 0) {
|
|
72
|
-
sign = 1;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
sign = -1;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return (0, format_to_parts_1.default)({ roundedNumber: x, formattedString: n, exponent: exponent, magnitude: magnitude, sign: sign }, internalSlots.dataLocaleData, pl, internalSlots);
|
|
79
|
-
}
|
|
80
|
-
exports.PartitionNumberPattern = PartitionNumberPattern;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { NumberFormatDigitOptions, NumberFormatNotation, NumberFormatDigitInternalSlots } from '../types/number';
|
|
2
|
-
/**
|
|
3
|
-
* https://tc39.es/ecma402/#sec-setnfdigitoptions
|
|
4
|
-
*/
|
|
5
|
-
export declare function SetNumberFormatDigitOptions(internalSlots: NumberFormatDigitInternalSlots, opts: NumberFormatDigitOptions, mnfdDefault: number, mxfdDefault: number, notation: NumberFormatNotation): void;
|
|
6
|
-
//# sourceMappingURL=SetNumberFormatDigitOptions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SetNumberFormatDigitOptions.d.ts","sourceRoot":"","sources":["../../../../../../packages/ecma402-abstract/NumberFormat/SetNumberFormatDigitOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,8BAA8B,EAC/B,MAAM,iBAAiB,CAAA;AAIxB;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,8BAA8B,EAC7C,IAAI,EAAE,wBAAwB,EAC9B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,oBAAoB,QA4B/B"}
|