@formatjs/ecma402-abstract 1.17.4 → 1.18.0
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/DefaultNumberOption.d.ts +1 -1
- package/DefaultNumberOption.js +16 -8
- package/GetNumberOption.d.ts +1 -1
- package/GetNumberOption.js +0 -1
- package/GetOption.d.ts +1 -1
- package/LICENSE.md +1 -1
- package/NumberFormat/SetNumberFormatDigitOptions.d.ts +1 -1
- package/NumberFormat/SetNumberFormatDigitOptions.js +2 -3
- package/lib/262.js +23 -49
- package/lib/CanonicalizeLocaleList.js +1 -5
- package/lib/CanonicalizeTimeZoneName.js +1 -5
- package/lib/CoerceOptionsToObject.js +3 -7
- package/lib/DefaultNumberOption.d.ts +1 -1
- package/lib/DefaultNumberOption.js +16 -12
- package/lib/GetNumberOption.d.ts +1 -1
- package/lib/GetNumberOption.js +3 -8
- package/lib/GetOption.d.ts +1 -1
- package/lib/GetOption.js +3 -7
- package/lib/GetOptionsObject.js +1 -5
- package/lib/GetStringOrBooleanOption.js +3 -7
- package/lib/IsSanctionedSimpleUnitIdentifier.js +5 -10
- package/lib/IsValidTimeZoneName.js +1 -5
- package/lib/IsWellFormedCurrencyCode.js +1 -5
- package/lib/IsWellFormedUnitIdentifier.js +5 -9
- package/lib/NumberFormat/ApplyUnsignedRoundingMode.js +1 -5
- package/lib/NumberFormat/CollapseNumberRange.js +1 -5
- package/lib/NumberFormat/ComputeExponent.js +9 -13
- package/lib/NumberFormat/ComputeExponentForMagnitude.js +1 -5
- package/lib/NumberFormat/CurrencyDigits.js +3 -7
- package/lib/NumberFormat/FormatApproximately.js +1 -5
- package/lib/NumberFormat/FormatNumericRange.js +3 -7
- package/lib/NumberFormat/FormatNumericRangeToParts.js +3 -7
- package/lib/NumberFormat/FormatNumericToParts.js +5 -9
- package/lib/NumberFormat/FormatNumericToString.js +11 -15
- package/lib/NumberFormat/GetUnsignedRoundingMode.js +1 -5
- package/lib/NumberFormat/InitializeNumberFormat.js +27 -31
- package/lib/NumberFormat/PartitionNumberPattern.js +11 -16
- package/lib/NumberFormat/PartitionNumberRangePattern.js +8 -12
- package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts +1 -1
- package/lib/NumberFormat/SetNumberFormatDigitOptions.js +11 -16
- package/lib/NumberFormat/SetNumberFormatUnitOptions.js +12 -16
- package/lib/NumberFormat/ToRawFixed.js +4 -8
- package/lib/NumberFormat/ToRawPrecision.js +7 -11
- package/lib/NumberFormat/digit-mapping.generated.js +1 -4
- package/lib/NumberFormat/format_to_parts.js +8 -11
- package/lib/PartitionPattern.js +3 -7
- package/lib/SupportedLocales.js +8 -12
- package/lib/data.js +3 -7
- package/lib/index.js +42 -56
- package/lib/regex.generated.js +1 -4
- package/lib/types/core.js +1 -2
- package/lib/types/date-time.js +2 -5
- package/lib/types/displaynames.js +1 -2
- package/lib/types/list.js +1 -2
- package/lib/types/number.js +1 -2
- package/lib/types/plural-rules.js +1 -2
- package/lib/types/relative-time.js +1 -2
- package/lib/utils.js +10 -22
- package/package.json +2 -2
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ToRawFixed = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
1
|
+
import { repeat } from '../utils';
|
|
5
2
|
/**
|
|
6
3
|
* TODO: dedup with intl-pluralrules and support BigInt
|
|
7
4
|
* https://tc39.es/ecma402/#sec-torawfixed
|
|
@@ -9,7 +6,7 @@ var utils_1 = require("../utils");
|
|
|
9
6
|
* @param minFraction and integer between 0 and 20
|
|
10
7
|
* @param maxFraction and integer between 0 and 20
|
|
11
8
|
*/
|
|
12
|
-
function ToRawFixed(x, minFraction, maxFraction) {
|
|
9
|
+
export function ToRawFixed(x, minFraction, maxFraction) {
|
|
13
10
|
var f = maxFraction;
|
|
14
11
|
var n = Math.round(x * Math.pow(10, f));
|
|
15
12
|
var xFinal = n / Math.pow(10, f);
|
|
@@ -24,13 +21,13 @@ function ToRawFixed(x, minFraction, maxFraction) {
|
|
|
24
21
|
m = n.toString();
|
|
25
22
|
var _a = m.split('e'), mantissa = _a[0], exponent = _a[1];
|
|
26
23
|
m = mantissa.replace('.', '');
|
|
27
|
-
m = m +
|
|
24
|
+
m = m + repeat('0', Math.max(+exponent - m.length + 1, 0));
|
|
28
25
|
}
|
|
29
26
|
var int;
|
|
30
27
|
if (f !== 0) {
|
|
31
28
|
var k = m.length;
|
|
32
29
|
if (k <= f) {
|
|
33
|
-
var z =
|
|
30
|
+
var z = repeat('0', f + 1 - k);
|
|
34
31
|
m = z + m;
|
|
35
32
|
k = f + 1;
|
|
36
33
|
}
|
|
@@ -52,4 +49,3 @@ function ToRawFixed(x, minFraction, maxFraction) {
|
|
|
52
49
|
}
|
|
53
50
|
return { formattedString: m, roundedNumber: xFinal, integerDigitsCount: int };
|
|
54
51
|
}
|
|
55
|
-
exports.ToRawFixed = ToRawFixed;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ToRawPrecision = void 0;
|
|
4
|
-
var utils_1 = require("../utils");
|
|
5
|
-
function ToRawPrecision(x, minPrecision, maxPrecision) {
|
|
1
|
+
import { repeat, getMagnitude } from '../utils';
|
|
2
|
+
export function ToRawPrecision(x, minPrecision, maxPrecision) {
|
|
6
3
|
var p = maxPrecision;
|
|
7
4
|
var m;
|
|
8
5
|
var e;
|
|
9
6
|
var xFinal;
|
|
10
7
|
if (x === 0) {
|
|
11
|
-
m =
|
|
8
|
+
m = repeat('0', p);
|
|
12
9
|
e = 0;
|
|
13
10
|
xFinal = 0;
|
|
14
11
|
}
|
|
@@ -26,11 +23,11 @@ function ToRawPrecision(x, minPrecision, maxPrecision) {
|
|
|
26
23
|
e = +xToStringExponent;
|
|
27
24
|
m =
|
|
28
25
|
xToStringMantissaWithoutDecimalPoint +
|
|
29
|
-
|
|
26
|
+
repeat('0', p - xToStringMantissaWithoutDecimalPoint.length);
|
|
30
27
|
xFinal = x;
|
|
31
28
|
}
|
|
32
29
|
else {
|
|
33
|
-
e =
|
|
30
|
+
e = getMagnitude(x);
|
|
34
31
|
var decimalPlaceOffset = e - p + 1;
|
|
35
32
|
// n is the integer containing the required precision digits. To derive the formatted string,
|
|
36
33
|
// we will adjust its decimal place in the logic below.
|
|
@@ -48,7 +45,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision) {
|
|
|
48
45
|
}
|
|
49
46
|
var int;
|
|
50
47
|
if (e >= p - 1) {
|
|
51
|
-
m = m +
|
|
48
|
+
m = m + repeat('0', e - p + 1);
|
|
52
49
|
int = e + 1;
|
|
53
50
|
}
|
|
54
51
|
else if (e >= 0) {
|
|
@@ -56,7 +53,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision) {
|
|
|
56
53
|
int = e + 1;
|
|
57
54
|
}
|
|
58
55
|
else {
|
|
59
|
-
m = "0.".concat(
|
|
56
|
+
m = "0.".concat(repeat('0', -e - 1)).concat(m);
|
|
60
57
|
int = 1;
|
|
61
58
|
}
|
|
62
59
|
if (m.indexOf('.') >= 0 && maxPrecision > minPrecision) {
|
|
@@ -75,4 +72,3 @@ function ToRawPrecision(x, minPrecision, maxPrecision) {
|
|
|
75
72
|
return magnitude < 0 ? x * Math.pow(10, -magnitude) : x / Math.pow(10, magnitude);
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
|
-
exports.ToRawPrecision = ToRawPrecision;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var digit_mapping_generated_1 = require("./digit-mapping.generated");
|
|
5
|
-
var regex_generated_1 = require("../regex.generated");
|
|
1
|
+
import { ToRawFixed } from './ToRawFixed';
|
|
2
|
+
import { digitMapping } from './digit-mapping.generated';
|
|
3
|
+
import { S_UNICODE_REGEX } from '../regex.generated';
|
|
6
4
|
// This is from: unicode-12.1.0/General_Category/Symbol/regex.js
|
|
7
5
|
// IE11 does not support unicode flag, otherwise this is just /\p{S}/u.
|
|
8
6
|
// /^\p{S}/u
|
|
9
|
-
var CARET_S_UNICODE_REGEX = new RegExp("^".concat(
|
|
7
|
+
var CARET_S_UNICODE_REGEX = new RegExp("^".concat(S_UNICODE_REGEX.source));
|
|
10
8
|
// /\p{S}$/u
|
|
11
|
-
var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(
|
|
9
|
+
var S_DOLLAR_UNICODE_REGEX = new RegExp("".concat(S_UNICODE_REGEX.source, "$"));
|
|
12
10
|
var CLDR_NUMBER_PATTERN = /[#0](?:[\.,][#0]+)*/g;
|
|
13
|
-
function formatToParts(numberResult, data, pl, options) {
|
|
11
|
+
export default function formatToParts(numberResult, data, pl, options) {
|
|
14
12
|
var sign = numberResult.sign, exponent = numberResult.exponent, magnitude = numberResult.magnitude;
|
|
15
13
|
var notation = options.notation, style = options.style, numberingSystem = options.numberingSystem;
|
|
16
14
|
var defaultNumberingSystem = data.numbers.nu[0];
|
|
@@ -251,7 +249,6 @@ function formatToParts(numberResult, data, pl, options) {
|
|
|
251
249
|
}
|
|
252
250
|
// #endregion
|
|
253
251
|
}
|
|
254
|
-
exports.default = formatToParts;
|
|
255
252
|
// A subset of https://tc39.es/ecma402/#sec-partitionnotationsubpattern
|
|
256
253
|
// Plus the exponent parts handling.
|
|
257
254
|
function paritionNumberIntoParts(symbols, numberResult, notation, exponent, numberingSystem, useGrouping,
|
|
@@ -272,7 +269,7 @@ decimalNumberPattern) {
|
|
|
272
269
|
else if (!isFinite(x)) {
|
|
273
270
|
return [{ type: 'infinity', value: n }];
|
|
274
271
|
}
|
|
275
|
-
var digitReplacementTable =
|
|
272
|
+
var digitReplacementTable = digitMapping[numberingSystem];
|
|
276
273
|
if (digitReplacementTable) {
|
|
277
274
|
n = n.replace(/\d/g, function (digit) { return digitReplacementTable[+digit] || digit; });
|
|
278
275
|
}
|
|
@@ -348,7 +345,7 @@ decimalNumberPattern) {
|
|
|
348
345
|
result.push({ type: 'exponentMinusSign', value: symbols.minusSign });
|
|
349
346
|
exponent = -exponent;
|
|
350
347
|
}
|
|
351
|
-
var exponentResult =
|
|
348
|
+
var exponentResult = ToRawFixed(exponent, 0, 0);
|
|
352
349
|
result.push({
|
|
353
350
|
type: 'exponentInteger',
|
|
354
351
|
value: exponentResult.formattedString,
|
package/lib/PartitionPattern.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PartitionPattern = void 0;
|
|
4
|
-
var utils_1 = require("./utils");
|
|
1
|
+
import { invariant } from './utils';
|
|
5
2
|
/**
|
|
6
3
|
* https://tc39.es/ecma402/#sec-partitionpattern
|
|
7
4
|
* @param pattern
|
|
8
5
|
*/
|
|
9
|
-
function PartitionPattern(pattern) {
|
|
6
|
+
export function PartitionPattern(pattern) {
|
|
10
7
|
var result = [];
|
|
11
8
|
var beginIndex = pattern.indexOf('{');
|
|
12
9
|
var endIndex = 0;
|
|
@@ -14,7 +11,7 @@ function PartitionPattern(pattern) {
|
|
|
14
11
|
var length = pattern.length;
|
|
15
12
|
while (beginIndex < pattern.length && beginIndex > -1) {
|
|
16
13
|
endIndex = pattern.indexOf('}', beginIndex);
|
|
17
|
-
|
|
14
|
+
invariant(endIndex > beginIndex, "Invalid pattern ".concat(pattern));
|
|
18
15
|
if (beginIndex > nextIndex) {
|
|
19
16
|
result.push({
|
|
20
17
|
type: 'literal',
|
|
@@ -36,4 +33,3 @@ function PartitionPattern(pattern) {
|
|
|
36
33
|
}
|
|
37
34
|
return result;
|
|
38
35
|
}
|
|
39
|
-
exports.PartitionPattern = PartitionPattern;
|
package/lib/SupportedLocales.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var intl_localematcher_1 = require("@formatjs/intl-localematcher");
|
|
5
|
-
var _262_1 = require("./262");
|
|
6
|
-
var GetOption_1 = require("./GetOption");
|
|
1
|
+
import { LookupSupportedLocales } from '@formatjs/intl-localematcher';
|
|
2
|
+
import { ToObject } from './262';
|
|
3
|
+
import { GetOption } from './GetOption';
|
|
7
4
|
/**
|
|
8
5
|
* https://tc39.es/ecma402/#sec-supportedlocales
|
|
9
6
|
* @param availableLocales
|
|
10
7
|
* @param requestedLocales
|
|
11
8
|
* @param options
|
|
12
9
|
*/
|
|
13
|
-
function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
10
|
+
export function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
14
11
|
var matcher = 'best fit';
|
|
15
12
|
if (options !== undefined) {
|
|
16
|
-
options =
|
|
17
|
-
matcher =
|
|
13
|
+
options = ToObject(options);
|
|
14
|
+
matcher = GetOption(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
|
|
18
15
|
}
|
|
19
16
|
if (matcher === 'best fit') {
|
|
20
|
-
return
|
|
17
|
+
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
21
18
|
}
|
|
22
|
-
return
|
|
19
|
+
return LookupSupportedLocales(Array.from(availableLocales), requestedLocales);
|
|
23
20
|
}
|
|
24
|
-
exports.SupportedLocales = SupportedLocales;
|
package/lib/data.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isMissingLocaleDataError = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
1
|
+
import { __extends } from "tslib";
|
|
5
2
|
var MissingLocaleDataError = /** @class */ (function (_super) {
|
|
6
|
-
|
|
3
|
+
__extends(MissingLocaleDataError, _super);
|
|
7
4
|
function MissingLocaleDataError() {
|
|
8
5
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
9
6
|
_this.type = 'MISSING_LOCALE_DATA';
|
|
@@ -11,7 +8,6 @@ var MissingLocaleDataError = /** @class */ (function (_super) {
|
|
|
11
8
|
}
|
|
12
9
|
return MissingLocaleDataError;
|
|
13
10
|
}(Error));
|
|
14
|
-
function isMissingLocaleDataError(e) {
|
|
11
|
+
export function isMissingLocaleDataError(e) {
|
|
15
12
|
return e.type === 'MISSING_LOCALE_DATA';
|
|
16
13
|
}
|
|
17
|
-
exports.isMissingLocaleDataError = isMissingLocaleDataError;
|
package/lib/index.js
CHANGED
|
@@ -1,56 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Object.defineProperty(exports, "setMultiInternalSlots", { enumerable: true, get: function () { return utils_1.setMultiInternalSlots; } });
|
|
44
|
-
Object.defineProperty(exports, "getMagnitude", { enumerable: true, get: function () { return utils_1.getMagnitude; } });
|
|
45
|
-
Object.defineProperty(exports, "defineProperty", { enumerable: true, get: function () { return utils_1.defineProperty; } });
|
|
46
|
-
var data_1 = require("./data");
|
|
47
|
-
Object.defineProperty(exports, "isMissingLocaleDataError", { enumerable: true, get: function () { return data_1.isMissingLocaleDataError; } });
|
|
48
|
-
tslib_1.__exportStar(require("./types/relative-time"), exports);
|
|
49
|
-
tslib_1.__exportStar(require("./types/date-time"), exports);
|
|
50
|
-
tslib_1.__exportStar(require("./types/list"), exports);
|
|
51
|
-
tslib_1.__exportStar(require("./types/plural-rules"), exports);
|
|
52
|
-
tslib_1.__exportStar(require("./types/number"), exports);
|
|
53
|
-
tslib_1.__exportStar(require("./types/displaynames"), exports);
|
|
54
|
-
var utils_2 = require("./utils");
|
|
55
|
-
Object.defineProperty(exports, "invariant", { enumerable: true, get: function () { return utils_2.invariant; } });
|
|
56
|
-
tslib_1.__exportStar(require("./262"), exports);
|
|
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 './GetStringOrBooleanOption';
|
|
8
|
+
export * from './IsSanctionedSimpleUnitIdentifier';
|
|
9
|
+
export * from './IsValidTimeZoneName';
|
|
10
|
+
export * from './IsWellFormedCurrencyCode';
|
|
11
|
+
export * from './IsWellFormedUnitIdentifier';
|
|
12
|
+
export * from './NumberFormat/ApplyUnsignedRoundingMode';
|
|
13
|
+
export * from './NumberFormat/CollapseNumberRange';
|
|
14
|
+
export * from './NumberFormat/ComputeExponent';
|
|
15
|
+
export * from './NumberFormat/ComputeExponentForMagnitude';
|
|
16
|
+
export * from './NumberFormat/CurrencyDigits';
|
|
17
|
+
export * from './NumberFormat/FormatApproximately';
|
|
18
|
+
export * from './NumberFormat/FormatNumericRange';
|
|
19
|
+
export * from './NumberFormat/FormatNumericRangeToParts';
|
|
20
|
+
export * from './NumberFormat/FormatNumericToParts';
|
|
21
|
+
export * from './NumberFormat/FormatNumericToString';
|
|
22
|
+
export * from './NumberFormat/GetUnsignedRoundingMode';
|
|
23
|
+
export * from './NumberFormat/InitializeNumberFormat';
|
|
24
|
+
export * from './NumberFormat/PartitionNumberPattern';
|
|
25
|
+
export * from './NumberFormat/PartitionNumberRangePattern';
|
|
26
|
+
export * from './NumberFormat/SetNumberFormatDigitOptions';
|
|
27
|
+
export * from './NumberFormat/SetNumberFormatUnitOptions';
|
|
28
|
+
export * from './NumberFormat/ToRawFixed';
|
|
29
|
+
export * from './NumberFormat/ToRawPrecision';
|
|
30
|
+
export { default as _formatToParts } from './NumberFormat/format_to_parts';
|
|
31
|
+
export * from './PartitionPattern';
|
|
32
|
+
export * from './SupportedLocales';
|
|
33
|
+
export { getInternalSlot, getMultiInternalSlots, isLiteralPart, setInternalSlot, setMultiInternalSlots, getMagnitude, defineProperty, } from './utils';
|
|
34
|
+
export { isMissingLocaleDataError } from './data';
|
|
35
|
+
export * from './types/relative-time';
|
|
36
|
+
export * from './types/date-time';
|
|
37
|
+
export * from './types/list';
|
|
38
|
+
export * from './types/plural-rules';
|
|
39
|
+
export * from './types/number';
|
|
40
|
+
export * from './types/displaynames';
|
|
41
|
+
export { invariant } from './utils';
|
|
42
|
+
export * from './262';
|
package/lib/regex.generated.js
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.S_UNICODE_REGEX = void 0;
|
|
4
1
|
// @generated from regex-gen.ts
|
|
5
|
-
|
|
2
|
+
export var S_UNICODE_REGEX = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20BF\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC1\uFDFC\uFDFD\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDE8\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEE0-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF73\uDF80-\uDFD8\uDFE0-\uDFEB]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDD78\uDD7A-\uDDCB\uDDCD-\uDE53\uDE60-\uDE6D\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6\uDF00-\uDF92\uDF94-\uDFCA]/;
|
package/lib/types/core.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/types/date-time.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RangePatternType = void 0;
|
|
4
|
-
var RangePatternType;
|
|
1
|
+
export var RangePatternType;
|
|
5
2
|
(function (RangePatternType) {
|
|
6
3
|
RangePatternType["startRange"] = "startRange";
|
|
7
4
|
RangePatternType["shared"] = "shared";
|
|
8
5
|
RangePatternType["endRange"] = "endRange";
|
|
9
|
-
})(RangePatternType || (
|
|
6
|
+
})(RangePatternType || (RangePatternType = {}));
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/types/list.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/types/number.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/utils.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.invariant = exports.UNICODE_EXTENSION_SEQUENCE_REGEX = exports.defineProperty = exports.isLiteralPart = exports.getMultiInternalSlots = exports.getInternalSlot = exports.setMultiInternalSlots = exports.setInternalSlot = exports.repeat = exports.getMagnitude = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Cannot do Math.log(x) / Math.log(10) bc if IEEE floating point issue
|
|
6
3
|
* @param x number
|
|
7
4
|
*/
|
|
8
|
-
function getMagnitude(x) {
|
|
5
|
+
export function getMagnitude(x) {
|
|
9
6
|
// Cannot count string length via Number.toString because it may use scientific notation
|
|
10
7
|
// for very small or very large numbers.
|
|
11
8
|
return Math.floor(Math.log(x) * Math.LOG10E);
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
function repeat(s, times) {
|
|
10
|
+
export function repeat(s, times) {
|
|
15
11
|
if (typeof s.repeat === 'function') {
|
|
16
12
|
return s.repeat(times);
|
|
17
13
|
}
|
|
@@ -21,27 +17,23 @@ function repeat(s, times) {
|
|
|
21
17
|
}
|
|
22
18
|
return arr.join('');
|
|
23
19
|
}
|
|
24
|
-
|
|
25
|
-
function setInternalSlot(map, pl, field, value) {
|
|
20
|
+
export function setInternalSlot(map, pl, field, value) {
|
|
26
21
|
if (!map.get(pl)) {
|
|
27
22
|
map.set(pl, Object.create(null));
|
|
28
23
|
}
|
|
29
24
|
var slots = map.get(pl);
|
|
30
25
|
slots[field] = value;
|
|
31
26
|
}
|
|
32
|
-
|
|
33
|
-
function setMultiInternalSlots(map, pl, props) {
|
|
27
|
+
export function setMultiInternalSlots(map, pl, props) {
|
|
34
28
|
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
|
|
35
29
|
var k = _a[_i];
|
|
36
30
|
setInternalSlot(map, pl, k, props[k]);
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
|
-
|
|
40
|
-
function getInternalSlot(map, pl, field) {
|
|
33
|
+
export function getInternalSlot(map, pl, field) {
|
|
41
34
|
return getMultiInternalSlots(map, pl, field)[field];
|
|
42
35
|
}
|
|
43
|
-
|
|
44
|
-
function getMultiInternalSlots(map, pl) {
|
|
36
|
+
export function getMultiInternalSlots(map, pl) {
|
|
45
37
|
var fields = [];
|
|
46
38
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
47
39
|
fields[_i - 2] = arguments[_i];
|
|
@@ -55,11 +47,9 @@ function getMultiInternalSlots(map, pl) {
|
|
|
55
47
|
return all;
|
|
56
48
|
}, Object.create(null));
|
|
57
49
|
}
|
|
58
|
-
|
|
59
|
-
function isLiteralPart(patternPart) {
|
|
50
|
+
export function isLiteralPart(patternPart) {
|
|
60
51
|
return patternPart.type === 'literal';
|
|
61
52
|
}
|
|
62
|
-
exports.isLiteralPart = isLiteralPart;
|
|
63
53
|
/*
|
|
64
54
|
17 ECMAScript Standard Built-in Objects:
|
|
65
55
|
Every built-in Function object, including constructors, that is not
|
|
@@ -70,7 +60,7 @@ exports.isLiteralPart = isLiteralPart;
|
|
|
70
60
|
object, if it exists, has the attributes { [[Writable]]: false,
|
|
71
61
|
[[Enumerable]]: false, [[Configurable]]: true }.
|
|
72
62
|
*/
|
|
73
|
-
function defineProperty(target, name, _a) {
|
|
63
|
+
export function defineProperty(target, name, _a) {
|
|
74
64
|
var value = _a.value;
|
|
75
65
|
Object.defineProperty(target, name, {
|
|
76
66
|
configurable: true,
|
|
@@ -79,12 +69,10 @@ function defineProperty(target, name, _a) {
|
|
|
79
69
|
value: value,
|
|
80
70
|
});
|
|
81
71
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
function invariant(condition, message, Err) {
|
|
72
|
+
export var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
73
|
+
export function invariant(condition, message, Err) {
|
|
85
74
|
if (Err === void 0) { Err = Error; }
|
|
86
75
|
if (!condition) {
|
|
87
76
|
throw new Err(message);
|
|
88
77
|
}
|
|
89
78
|
}
|
|
90
|
-
exports.invariant = invariant;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formatjs/ecma402-abstract",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "A collection of implementation for ECMAScript abstract operations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intl",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"tslib": "^2.4.0",
|
|
18
|
-
"@formatjs/intl-localematcher": "0.5.
|
|
18
|
+
"@formatjs/intl-localematcher": "0.5.2"
|
|
19
19
|
},
|
|
20
20
|
"author": "Long Ho <holevietlong@gmail.com",
|
|
21
21
|
"bugs": {
|