@formatjs/ecma402-abstract 2.3.5 → 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.
Files changed (177) hide show
  1. package/262.d.ts +1 -1
  2. package/262.js +42 -68
  3. package/CanonicalizeLocaleList.js +1 -4
  4. package/CanonicalizeTimeZoneName.js +1 -4
  5. package/CoerceOptionsToObject.js +3 -6
  6. package/DefaultNumberOption.js +1 -4
  7. package/GetNumberOption.js +3 -6
  8. package/GetOption.js +3 -6
  9. package/GetOptionsObject.js +1 -4
  10. package/GetStringOrBooleanOption.js +3 -6
  11. package/IsSanctionedSimpleUnitIdentifier.js +5 -10
  12. package/IsValidTimeZoneName.js +1 -4
  13. package/IsWellFormedCurrencyCode.js +1 -4
  14. package/IsWellFormedUnitIdentifier.js +5 -8
  15. package/NumberFormat/ApplyUnsignedRoundingMode.d.ts +2 -2
  16. package/NumberFormat/ApplyUnsignedRoundingMode.js +5 -8
  17. package/NumberFormat/CollapseNumberRange.d.ts +1 -1
  18. package/NumberFormat/CollapseNumberRange.js +1 -4
  19. package/NumberFormat/ComputeExponent.d.ts +2 -2
  20. package/NumberFormat/ComputeExponent.js +8 -12
  21. package/NumberFormat/ComputeExponentForMagnitude.d.ts +2 -2
  22. package/NumberFormat/ComputeExponentForMagnitude.js +6 -10
  23. package/NumberFormat/CurrencyDigits.js +3 -6
  24. package/NumberFormat/FormatApproximately.d.ts +1 -1
  25. package/NumberFormat/FormatApproximately.js +1 -4
  26. package/NumberFormat/FormatNumeric.d.ts +2 -2
  27. package/NumberFormat/FormatNumeric.js +3 -6
  28. package/NumberFormat/FormatNumericRange.d.ts +2 -2
  29. package/NumberFormat/FormatNumericRange.js +3 -6
  30. package/NumberFormat/FormatNumericRangeToParts.d.ts +2 -2
  31. package/NumberFormat/FormatNumericRangeToParts.js +3 -6
  32. package/NumberFormat/FormatNumericToParts.d.ts +2 -2
  33. package/NumberFormat/FormatNumericToParts.js +5 -8
  34. package/NumberFormat/FormatNumericToString.d.ts +2 -2
  35. package/NumberFormat/FormatNumericToString.js +16 -19
  36. package/NumberFormat/GetUnsignedRoundingMode.d.ts +1 -1
  37. package/NumberFormat/GetUnsignedRoundingMode.js +1 -4
  38. package/NumberFormat/InitializeNumberFormat.d.ts +1 -1
  39. package/NumberFormat/InitializeNumberFormat.js +23 -26
  40. package/NumberFormat/PartitionNumberPattern.d.ts +2 -2
  41. package/NumberFormat/PartitionNumberPattern.js +12 -16
  42. package/NumberFormat/PartitionNumberRangePattern.d.ts +2 -2
  43. package/NumberFormat/PartitionNumberRangePattern.js +12 -15
  44. package/NumberFormat/SetNumberFormatDigitOptions.d.ts +1 -1
  45. package/NumberFormat/SetNumberFormatDigitOptions.js +18 -21
  46. package/NumberFormat/SetNumberFormatUnitOptions.d.ts +1 -1
  47. package/NumberFormat/SetNumberFormatUnitOptions.js +15 -18
  48. package/NumberFormat/ToRawFixed.d.ts +2 -2
  49. package/NumberFormat/ToRawFixed.js +10 -14
  50. package/NumberFormat/ToRawPrecision.d.ts +2 -2
  51. package/NumberFormat/ToRawPrecision.js +19 -23
  52. package/NumberFormat/digit-mapping.generated.js +1 -4
  53. package/NumberFormat/format_to_parts.d.ts +2 -2
  54. package/NumberFormat/format_to_parts.js +18 -22
  55. package/PartitionPattern.d.ts +1 -0
  56. package/PartitionPattern.js +4 -6
  57. package/SupportedLocales.js +8 -11
  58. package/ToIntlMathematicalValue.d.ts +1 -1
  59. package/ToIntlMathematicalValue.js +12 -16
  60. package/constants.d.ts +1 -1
  61. package/constants.js +4 -8
  62. package/data.js +3 -6
  63. package/index.d.ts +47 -47
  64. package/index.js +45 -66
  65. package/package.json +7 -5
  66. package/regex.generated.js +1 -4
  67. package/types/core.js +1 -2
  68. package/types/date-time.js +2 -5
  69. package/types/displaynames.d.ts +1 -1
  70. package/types/displaynames.js +1 -2
  71. package/types/list.d.ts +1 -1
  72. package/types/list.js +1 -2
  73. package/types/number.d.ts +3 -3
  74. package/types/number.js +1 -2
  75. package/types/plural-rules.d.ts +2 -2
  76. package/types/plural-rules.js +1 -2
  77. package/types/relative-time.d.ts +2 -2
  78. package/types/relative-time.js +1 -2
  79. package/utils.js +28 -40
  80. package/lib/262.d.ts +0 -93
  81. package/lib/262.js +0 -400
  82. package/lib/CanonicalizeLocaleList.d.ts +0 -5
  83. package/lib/CanonicalizeLocaleList.js +0 -8
  84. package/lib/CanonicalizeTimeZoneName.d.ts +0 -8
  85. package/lib/CanonicalizeTimeZoneName.js +0 -17
  86. package/lib/CoerceOptionsToObject.d.ts +0 -6
  87. package/lib/CoerceOptionsToObject.js +0 -12
  88. package/lib/DefaultNumberOption.d.ts +0 -8
  89. package/lib/DefaultNumberOption.js +0 -18
  90. package/lib/GetNumberOption.d.ts +0 -9
  91. package/lib/GetNumberOption.js +0 -13
  92. package/lib/GetOption.d.ts +0 -9
  93. package/lib/GetOption.js +0 -31
  94. package/lib/GetOptionsObject.d.ts +0 -6
  95. package/lib/GetOptionsObject.js +0 -14
  96. package/lib/GetStringOrBooleanOption.d.ts +0 -10
  97. package/lib/GetStringOrBooleanOption.js +0 -31
  98. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts +0 -13
  99. package/lib/IsSanctionedSimpleUnitIdentifier.js +0 -63
  100. package/lib/IsValidTimeZoneName.d.ts +0 -9
  101. package/lib/IsValidTimeZoneName.js +0 -17
  102. package/lib/IsWellFormedCurrencyCode.d.ts +0 -4
  103. package/lib/IsWellFormedCurrencyCode.js +0 -21
  104. package/lib/IsWellFormedUnitIdentifier.d.ts +0 -5
  105. package/lib/IsWellFormedUnitIdentifier.js +0 -28
  106. package/lib/NumberFormat/ApplyUnsignedRoundingMode.d.ts +0 -3
  107. package/lib/NumberFormat/ApplyUnsignedRoundingMode.js +0 -33
  108. package/lib/NumberFormat/CollapseNumberRange.d.ts +0 -8
  109. package/lib/NumberFormat/CollapseNumberRange.js +0 -50
  110. package/lib/NumberFormat/ComputeExponent.d.ts +0 -10
  111. package/lib/NumberFormat/ComputeExponent.js +0 -34
  112. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts +0 -8
  113. package/lib/NumberFormat/ComputeExponentForMagnitude.js +0 -65
  114. package/lib/NumberFormat/CurrencyDigits.d.ts +0 -6
  115. package/lib/NumberFormat/CurrencyDigits.js +0 -10
  116. package/lib/NumberFormat/FormatApproximately.d.ts +0 -5
  117. package/lib/NumberFormat/FormatApproximately.js +0 -9
  118. package/lib/NumberFormat/FormatNumeric.d.ts +0 -3
  119. package/lib/NumberFormat/FormatNumeric.js +0 -5
  120. package/lib/NumberFormat/FormatNumericRange.d.ts +0 -8
  121. package/lib/NumberFormat/FormatNumericRange.js +0 -11
  122. package/lib/NumberFormat/FormatNumericRangeToParts.d.ts +0 -8
  123. package/lib/NumberFormat/FormatNumericRangeToParts.js +0 -16
  124. package/lib/NumberFormat/FormatNumericToParts.d.ts +0 -5
  125. package/lib/NumberFormat/FormatNumericToParts.js +0 -14
  126. package/lib/NumberFormat/FormatNumericToString.d.ts +0 -9
  127. package/lib/NumberFormat/FormatNumericToString.js +0 -84
  128. package/lib/NumberFormat/GetUnsignedRoundingMode.d.ts +0 -2
  129. package/lib/NumberFormat/GetUnsignedRoundingMode.js +0 -28
  130. package/lib/NumberFormat/InitializeNumberFormat.d.ts +0 -12
  131. package/lib/NumberFormat/InitializeNumberFormat.js +0 -66
  132. package/lib/NumberFormat/PartitionNumberPattern.d.ts +0 -6
  133. package/lib/NumberFormat/PartitionNumberPattern.js +0 -126
  134. package/lib/NumberFormat/PartitionNumberRangePattern.d.ts +0 -8
  135. package/lib/NumberFormat/PartitionNumberRangePattern.js +0 -40
  136. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts +0 -5
  137. package/lib/NumberFormat/SetNumberFormatDigitOptions.js +0 -179
  138. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts +0 -5
  139. package/lib/NumberFormat/SetNumberFormatUnitOptions.js +0 -50
  140. package/lib/NumberFormat/ToRawFixed.d.ts +0 -9
  141. package/lib/NumberFormat/ToRawFixed.js +0 -119
  142. package/lib/NumberFormat/ToRawPrecision.d.ts +0 -9
  143. package/lib/NumberFormat/ToRawPrecision.js +0 -148
  144. package/lib/NumberFormat/digit-mapping.generated.d.ts +0 -1
  145. package/lib/NumberFormat/digit-mapping.generated.js +0 -782
  146. package/lib/NumberFormat/format_to_parts.d.ts +0 -24
  147. package/lib/NumberFormat/format_to_parts.js +0 -447
  148. package/lib/PartitionPattern.d.ts +0 -8
  149. package/lib/PartitionPattern.js +0 -35
  150. package/lib/SupportedLocales.d.ts +0 -9
  151. package/lib/SupportedLocales.js +0 -20
  152. package/lib/ToIntlMathematicalValue.d.ts +0 -2
  153. package/lib/ToIntlMathematicalValue.js +0 -27
  154. package/lib/constants.d.ts +0 -4
  155. package/lib/constants.js +0 -4
  156. package/lib/data.d.ts +0 -5
  157. package/lib/data.js +0 -13
  158. package/lib/index.d.ts +0 -47
  159. package/lib/index.js +0 -45
  160. package/lib/regex.generated.d.ts +0 -1
  161. package/lib/regex.generated.js +0 -2
  162. package/lib/types/core.d.ts +0 -10
  163. package/lib/types/core.js +0 -1
  164. package/lib/types/date-time.d.ts +0 -135
  165. package/lib/types/date-time.js +0 -6
  166. package/lib/types/displaynames.d.ts +0 -65
  167. package/lib/types/displaynames.js +0 -1
  168. package/lib/types/list.d.ts +0 -18
  169. package/lib/types/list.js +0 -1
  170. package/lib/types/number.d.ts +0 -173
  171. package/lib/types/number.js +0 -1
  172. package/lib/types/plural-rules.d.ts +0 -16
  173. package/lib/types/plural-rules.js +0 -1
  174. package/lib/types/relative-time.d.ts +0 -40
  175. package/lib/types/relative-time.js +0 -1
  176. package/lib/utils.d.ts +0 -30
  177. 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
- });