@formatjs/ecma402-abstract 2.3.6 → 3.0.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/262.d.ts +1 -1
- package/262.js +42 -68
- package/CanonicalizeLocaleList.js +1 -4
- package/CanonicalizeTimeZoneName.js +1 -4
- package/CoerceOptionsToObject.js +3 -6
- package/DefaultNumberOption.js +1 -4
- package/GetNumberOption.js +3 -6
- package/GetOption.js +3 -6
- package/GetOptionsObject.js +1 -4
- package/GetStringOrBooleanOption.js +3 -6
- package/IsSanctionedSimpleUnitIdentifier.js +5 -10
- package/IsValidTimeZoneName.js +1 -4
- package/IsWellFormedCurrencyCode.js +1 -4
- package/IsWellFormedUnitIdentifier.js +5 -8
- package/NumberFormat/ApplyUnsignedRoundingMode.d.ts +2 -2
- package/NumberFormat/ApplyUnsignedRoundingMode.js +5 -8
- package/NumberFormat/CollapseNumberRange.d.ts +1 -1
- package/NumberFormat/CollapseNumberRange.js +1 -4
- package/NumberFormat/ComputeExponent.d.ts +2 -2
- package/NumberFormat/ComputeExponent.js +8 -12
- package/NumberFormat/ComputeExponentForMagnitude.d.ts +2 -2
- package/NumberFormat/ComputeExponentForMagnitude.js +6 -10
- package/NumberFormat/CurrencyDigits.js +3 -6
- package/NumberFormat/FormatApproximately.d.ts +1 -1
- package/NumberFormat/FormatApproximately.js +1 -4
- package/NumberFormat/FormatNumeric.d.ts +2 -2
- package/NumberFormat/FormatNumeric.js +3 -6
- package/NumberFormat/FormatNumericRange.d.ts +2 -2
- package/NumberFormat/FormatNumericRange.js +3 -6
- package/NumberFormat/FormatNumericRangeToParts.d.ts +2 -2
- package/NumberFormat/FormatNumericRangeToParts.js +3 -6
- package/NumberFormat/FormatNumericToParts.d.ts +2 -2
- package/NumberFormat/FormatNumericToParts.js +5 -8
- package/NumberFormat/FormatNumericToString.d.ts +2 -2
- package/NumberFormat/FormatNumericToString.js +16 -19
- package/NumberFormat/GetUnsignedRoundingMode.d.ts +1 -1
- package/NumberFormat/GetUnsignedRoundingMode.js +1 -4
- package/NumberFormat/InitializeNumberFormat.d.ts +1 -1
- package/NumberFormat/InitializeNumberFormat.js +23 -26
- package/NumberFormat/PartitionNumberPattern.d.ts +2 -2
- package/NumberFormat/PartitionNumberPattern.js +12 -16
- package/NumberFormat/PartitionNumberRangePattern.d.ts +2 -2
- package/NumberFormat/PartitionNumberRangePattern.js +12 -15
- package/NumberFormat/SetNumberFormatDigitOptions.d.ts +1 -1
- package/NumberFormat/SetNumberFormatDigitOptions.js +18 -21
- package/NumberFormat/SetNumberFormatUnitOptions.d.ts +1 -1
- package/NumberFormat/SetNumberFormatUnitOptions.js +15 -18
- package/NumberFormat/ToRawFixed.d.ts +2 -2
- package/NumberFormat/ToRawFixed.js +10 -14
- package/NumberFormat/ToRawPrecision.d.ts +2 -2
- package/NumberFormat/ToRawPrecision.js +19 -23
- package/NumberFormat/digit-mapping.generated.js +1 -4
- package/NumberFormat/format_to_parts.d.ts +2 -2
- package/NumberFormat/format_to_parts.js +18 -22
- package/PartitionPattern.js +3 -6
- package/SupportedLocales.js +8 -11
- package/ToIntlMathematicalValue.d.ts +1 -1
- package/ToIntlMathematicalValue.js +12 -16
- package/constants.d.ts +1 -1
- package/constants.js +4 -8
- package/data.js +3 -6
- package/index.d.ts +47 -47
- package/index.js +45 -66
- package/package.json +13 -11
- package/regex.generated.js +1 -4
- package/types/core.js +1 -2
- package/types/date-time.js +2 -5
- package/types/displaynames.d.ts +1 -1
- package/types/displaynames.js +1 -2
- package/types/list.d.ts +1 -1
- package/types/list.js +1 -2
- package/types/number.d.ts +3 -3
- package/types/number.js +1 -2
- package/types/plural-rules.d.ts +2 -2
- package/types/plural-rules.js +1 -2
- package/types/relative-time.d.ts +2 -2
- package/types/relative-time.js +1 -2
- package/utils.js +28 -40
- package/lib/262.d.ts +0 -93
- package/lib/262.js +0 -400
- package/lib/CanonicalizeLocaleList.d.ts +0 -5
- package/lib/CanonicalizeLocaleList.js +0 -8
- package/lib/CanonicalizeTimeZoneName.d.ts +0 -8
- package/lib/CanonicalizeTimeZoneName.js +0 -17
- package/lib/CoerceOptionsToObject.d.ts +0 -6
- package/lib/CoerceOptionsToObject.js +0 -12
- package/lib/DefaultNumberOption.d.ts +0 -8
- package/lib/DefaultNumberOption.js +0 -18
- package/lib/GetNumberOption.d.ts +0 -9
- package/lib/GetNumberOption.js +0 -13
- package/lib/GetOption.d.ts +0 -9
- package/lib/GetOption.js +0 -31
- package/lib/GetOptionsObject.d.ts +0 -6
- package/lib/GetOptionsObject.js +0 -14
- package/lib/GetStringOrBooleanOption.d.ts +0 -10
- package/lib/GetStringOrBooleanOption.js +0 -31
- package/lib/IsSanctionedSimpleUnitIdentifier.d.ts +0 -13
- package/lib/IsSanctionedSimpleUnitIdentifier.js +0 -63
- package/lib/IsValidTimeZoneName.d.ts +0 -9
- package/lib/IsValidTimeZoneName.js +0 -17
- package/lib/IsWellFormedCurrencyCode.d.ts +0 -4
- package/lib/IsWellFormedCurrencyCode.js +0 -21
- package/lib/IsWellFormedUnitIdentifier.d.ts +0 -5
- package/lib/IsWellFormedUnitIdentifier.js +0 -28
- package/lib/NumberFormat/ApplyUnsignedRoundingMode.d.ts +0 -3
- package/lib/NumberFormat/ApplyUnsignedRoundingMode.js +0 -33
- package/lib/NumberFormat/CollapseNumberRange.d.ts +0 -8
- package/lib/NumberFormat/CollapseNumberRange.js +0 -50
- package/lib/NumberFormat/ComputeExponent.d.ts +0 -10
- package/lib/NumberFormat/ComputeExponent.js +0 -34
- package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts +0 -8
- package/lib/NumberFormat/ComputeExponentForMagnitude.js +0 -65
- package/lib/NumberFormat/CurrencyDigits.d.ts +0 -6
- package/lib/NumberFormat/CurrencyDigits.js +0 -10
- package/lib/NumberFormat/FormatApproximately.d.ts +0 -5
- package/lib/NumberFormat/FormatApproximately.js +0 -9
- package/lib/NumberFormat/FormatNumeric.d.ts +0 -3
- package/lib/NumberFormat/FormatNumeric.js +0 -5
- package/lib/NumberFormat/FormatNumericRange.d.ts +0 -8
- package/lib/NumberFormat/FormatNumericRange.js +0 -11
- package/lib/NumberFormat/FormatNumericRangeToParts.d.ts +0 -8
- package/lib/NumberFormat/FormatNumericRangeToParts.js +0 -16
- package/lib/NumberFormat/FormatNumericToParts.d.ts +0 -5
- package/lib/NumberFormat/FormatNumericToParts.js +0 -14
- package/lib/NumberFormat/FormatNumericToString.d.ts +0 -9
- package/lib/NumberFormat/FormatNumericToString.js +0 -84
- package/lib/NumberFormat/GetUnsignedRoundingMode.d.ts +0 -2
- package/lib/NumberFormat/GetUnsignedRoundingMode.js +0 -28
- package/lib/NumberFormat/InitializeNumberFormat.d.ts +0 -12
- package/lib/NumberFormat/InitializeNumberFormat.js +0 -66
- package/lib/NumberFormat/PartitionNumberPattern.d.ts +0 -6
- package/lib/NumberFormat/PartitionNumberPattern.js +0 -126
- package/lib/NumberFormat/PartitionNumberRangePattern.d.ts +0 -8
- package/lib/NumberFormat/PartitionNumberRangePattern.js +0 -40
- package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts +0 -5
- package/lib/NumberFormat/SetNumberFormatDigitOptions.js +0 -179
- package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts +0 -5
- package/lib/NumberFormat/SetNumberFormatUnitOptions.js +0 -50
- package/lib/NumberFormat/ToRawFixed.d.ts +0 -9
- package/lib/NumberFormat/ToRawFixed.js +0 -119
- package/lib/NumberFormat/ToRawPrecision.d.ts +0 -9
- package/lib/NumberFormat/ToRawPrecision.js +0 -148
- package/lib/NumberFormat/digit-mapping.generated.d.ts +0 -1
- package/lib/NumberFormat/digit-mapping.generated.js +0 -782
- package/lib/NumberFormat/format_to_parts.d.ts +0 -24
- package/lib/NumberFormat/format_to_parts.js +0 -447
- package/lib/PartitionPattern.d.ts +0 -9
- package/lib/PartitionPattern.js +0 -36
- package/lib/SupportedLocales.d.ts +0 -9
- package/lib/SupportedLocales.js +0 -20
- package/lib/ToIntlMathematicalValue.d.ts +0 -2
- package/lib/ToIntlMathematicalValue.js +0 -27
- package/lib/constants.d.ts +0 -4
- package/lib/constants.js +0 -4
- package/lib/data.d.ts +0 -5
- package/lib/data.js +0 -13
- package/lib/index.d.ts +0 -47
- package/lib/index.js +0 -45
- package/lib/regex.generated.d.ts +0 -1
- package/lib/regex.generated.js +0 -2
- package/lib/types/core.d.ts +0 -10
- package/lib/types/core.js +0 -1
- package/lib/types/date-time.d.ts +0 -135
- package/lib/types/date-time.js +0 -6
- package/lib/types/displaynames.d.ts +0 -65
- package/lib/types/displaynames.js +0 -1
- package/lib/types/list.d.ts +0 -18
- package/lib/types/list.js +0 -1
- package/lib/types/number.d.ts +0 -173
- package/lib/types/number.js +0 -1
- package/lib/types/plural-rules.d.ts +0 -16
- package/lib/types/plural-rules.js +0 -1
- package/lib/types/relative-time.d.ts +0 -40
- package/lib/types/relative-time.js +0 -1
- package/lib/utils.d.ts +0 -30
- package/lib/utils.js +0 -135
package/lib/utils.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { __spreadArray } from "tslib";
|
|
2
|
-
import { memoize, strategies } from '@formatjs/fast-memoize';
|
|
3
|
-
export function repeat(s, times) {
|
|
4
|
-
if (typeof s.repeat === 'function') {
|
|
5
|
-
return s.repeat(times);
|
|
6
|
-
}
|
|
7
|
-
var arr = new Array(times);
|
|
8
|
-
for (var i = 0; i < arr.length; i++) {
|
|
9
|
-
arr[i] = s;
|
|
10
|
-
}
|
|
11
|
-
return arr.join('');
|
|
12
|
-
}
|
|
13
|
-
export function setInternalSlot(map, pl, field, value) {
|
|
14
|
-
if (!map.get(pl)) {
|
|
15
|
-
map.set(pl, Object.create(null));
|
|
16
|
-
}
|
|
17
|
-
var slots = map.get(pl);
|
|
18
|
-
slots[field] = value;
|
|
19
|
-
}
|
|
20
|
-
export function setMultiInternalSlots(map, pl, props) {
|
|
21
|
-
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
|
|
22
|
-
var k = _a[_i];
|
|
23
|
-
setInternalSlot(map, pl, k, props[k]);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
export function getInternalSlot(map, pl, field) {
|
|
27
|
-
return getMultiInternalSlots(map, pl, field)[field];
|
|
28
|
-
}
|
|
29
|
-
export function getMultiInternalSlots(map, pl) {
|
|
30
|
-
var fields = [];
|
|
31
|
-
for (var _i = 2; _i < arguments.length; _i++) {
|
|
32
|
-
fields[_i - 2] = arguments[_i];
|
|
33
|
-
}
|
|
34
|
-
var slots = map.get(pl);
|
|
35
|
-
if (!slots) {
|
|
36
|
-
throw new TypeError("".concat(pl, " InternalSlot has not been initialized"));
|
|
37
|
-
}
|
|
38
|
-
return fields.reduce(function (all, f) {
|
|
39
|
-
all[f] = slots[f];
|
|
40
|
-
return all;
|
|
41
|
-
}, Object.create(null));
|
|
42
|
-
}
|
|
43
|
-
export function isLiteralPart(patternPart) {
|
|
44
|
-
return patternPart.type === 'literal';
|
|
45
|
-
}
|
|
46
|
-
/*
|
|
47
|
-
17 ECMAScript Standard Built-in Objects:
|
|
48
|
-
Every built-in Function object, including constructors, that is not
|
|
49
|
-
identified as an anonymous function has a name property whose value
|
|
50
|
-
is a String.
|
|
51
|
-
|
|
52
|
-
Unless otherwise specified, the name property of a built-in Function
|
|
53
|
-
object, if it exists, has the attributes { [[Writable]]: false,
|
|
54
|
-
[[Enumerable]]: false, [[Configurable]]: true }.
|
|
55
|
-
*/
|
|
56
|
-
export function defineProperty(target, name, _a) {
|
|
57
|
-
var value = _a.value;
|
|
58
|
-
Object.defineProperty(target, name, {
|
|
59
|
-
configurable: true,
|
|
60
|
-
enumerable: false,
|
|
61
|
-
writable: true,
|
|
62
|
-
value: value,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* 7.3.5 CreateDataProperty
|
|
67
|
-
* @param target
|
|
68
|
-
* @param name
|
|
69
|
-
* @param value
|
|
70
|
-
*/
|
|
71
|
-
export function createDataProperty(target, name, value) {
|
|
72
|
-
Object.defineProperty(target, name, {
|
|
73
|
-
configurable: true,
|
|
74
|
-
enumerable: true,
|
|
75
|
-
writable: true,
|
|
76
|
-
value: value,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
export var UNICODE_EXTENSION_SEQUENCE_REGEX = /-u(?:-[0-9a-z]{2,8})+/gi;
|
|
80
|
-
export function invariant(condition, message, Err) {
|
|
81
|
-
if (Err === void 0) { Err = Error; }
|
|
82
|
-
if (!condition) {
|
|
83
|
-
throw new Err(message);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
export var createMemoizedNumberFormat = memoize(function () {
|
|
87
|
-
var _a;
|
|
88
|
-
var args = [];
|
|
89
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
90
|
-
args[_i] = arguments[_i];
|
|
91
|
-
}
|
|
92
|
-
return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
|
|
93
|
-
}, {
|
|
94
|
-
strategy: strategies.variadic,
|
|
95
|
-
});
|
|
96
|
-
export var createMemoizedDateTimeFormat = memoize(function () {
|
|
97
|
-
var _a;
|
|
98
|
-
var args = [];
|
|
99
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
100
|
-
args[_i] = arguments[_i];
|
|
101
|
-
}
|
|
102
|
-
return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
|
|
103
|
-
}, {
|
|
104
|
-
strategy: strategies.variadic,
|
|
105
|
-
});
|
|
106
|
-
export var createMemoizedPluralRules = memoize(function () {
|
|
107
|
-
var _a;
|
|
108
|
-
var args = [];
|
|
109
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
110
|
-
args[_i] = arguments[_i];
|
|
111
|
-
}
|
|
112
|
-
return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();
|
|
113
|
-
}, {
|
|
114
|
-
strategy: strategies.variadic,
|
|
115
|
-
});
|
|
116
|
-
export var createMemoizedLocale = memoize(function () {
|
|
117
|
-
var _a;
|
|
118
|
-
var args = [];
|
|
119
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
120
|
-
args[_i] = arguments[_i];
|
|
121
|
-
}
|
|
122
|
-
return new ((_a = Intl.Locale).bind.apply(_a, __spreadArray([void 0], args, false)))();
|
|
123
|
-
}, {
|
|
124
|
-
strategy: strategies.variadic,
|
|
125
|
-
});
|
|
126
|
-
export var createMemoizedListFormat = memoize(function () {
|
|
127
|
-
var _a;
|
|
128
|
-
var args = [];
|
|
129
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
130
|
-
args[_i] = arguments[_i];
|
|
131
|
-
}
|
|
132
|
-
return new ((_a = Intl.ListFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
|
|
133
|
-
}, {
|
|
134
|
-
strategy: strategies.variadic,
|
|
135
|
-
});
|