@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/262.d.ts CHANGED
@@ -86,7 +86,7 @@ export declare function SecFromTime(t: number): number;
86
86
  * @param O object
87
87
  * @param internalSlots internalSlots
88
88
  */
89
- export declare function OrdinaryHasInstance(C: Object, O: any, internalSlots?: {
89
+ export declare function OrdinaryHasInstance(C: object, O: any, internalSlots?: {
90
90
  boundTargetFunction: any;
91
91
  }): boolean;
92
92
  export declare function msFromTime(t: number): number;
package/262.js CHANGED
@@ -1,36 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToString = ToString;
4
- exports.ToNumber = ToNumber;
5
- exports.TimeClip = TimeClip;
6
- exports.ToObject = ToObject;
7
- exports.SameValue = SameValue;
8
- exports.ArrayCreate = ArrayCreate;
9
- exports.HasOwnProperty = HasOwnProperty;
10
- exports.Type = Type;
11
- exports.Day = Day;
12
- exports.WeekDay = WeekDay;
13
- exports.DayFromYear = DayFromYear;
14
- exports.TimeFromYear = TimeFromYear;
15
- exports.YearFromTime = YearFromTime;
16
- exports.DaysInYear = DaysInYear;
17
- exports.DayWithinYear = DayWithinYear;
18
- exports.InLeapYear = InLeapYear;
19
- exports.MonthFromTime = MonthFromTime;
20
- exports.DateFromTime = DateFromTime;
21
- exports.HourFromTime = HourFromTime;
22
- exports.MinFromTime = MinFromTime;
23
- exports.SecFromTime = SecFromTime;
24
- exports.OrdinaryHasInstance = OrdinaryHasInstance;
25
- exports.msFromTime = msFromTime;
26
- exports.ToPrimitive = ToPrimitive;
27
- var decimal_js_1 = require("decimal.js");
28
- var constants_1 = require("./constants");
29
- var utils_1 = require("./utils");
1
+ import { Decimal } from 'decimal.js';
2
+ import { ZERO } from './constants.js';
3
+ import { invariant } from './utils.js';
30
4
  /**
31
5
  * https://tc39.es/ecma262/#sec-tostring
32
6
  */
33
- function ToString(o) {
7
+ export function ToString(o) {
34
8
  // Only symbol is irregular...
35
9
  if (typeof o === 'symbol') {
36
10
  throw TypeError('Cannot convert a Symbol value to a string');
@@ -41,31 +15,31 @@ function ToString(o) {
41
15
  * https://tc39.es/ecma262/#sec-tonumber
42
16
  * @param val
43
17
  */
44
- function ToNumber(arg) {
18
+ export function ToNumber(arg) {
45
19
  if (typeof arg === 'number') {
46
- return new decimal_js_1.Decimal(arg);
20
+ return new Decimal(arg);
47
21
  }
48
- (0, utils_1.invariant)(typeof arg !== 'bigint' && typeof arg !== 'symbol', 'BigInt and Symbol are not supported', TypeError);
22
+ invariant(typeof arg !== 'bigint' && typeof arg !== 'symbol', 'BigInt and Symbol are not supported', TypeError);
49
23
  if (arg === undefined) {
50
- return new decimal_js_1.Decimal(NaN);
24
+ return new Decimal(NaN);
51
25
  }
52
26
  if (arg === null || arg === 0) {
53
- return constants_1.ZERO;
27
+ return ZERO;
54
28
  }
55
29
  if (arg === true) {
56
- return new decimal_js_1.Decimal(1);
30
+ return new Decimal(1);
57
31
  }
58
32
  if (typeof arg === 'string') {
59
33
  try {
60
- return new decimal_js_1.Decimal(arg);
34
+ return new Decimal(arg);
61
35
  }
62
- catch (e) {
63
- return new decimal_js_1.Decimal(NaN);
36
+ catch (_a) {
37
+ return new Decimal(NaN);
64
38
  }
65
39
  }
66
- (0, utils_1.invariant)(typeof arg === 'object', 'object expected', TypeError);
40
+ invariant(typeof arg === 'object', 'object expected', TypeError);
67
41
  var primValue = ToPrimitive(arg, 'number');
68
- (0, utils_1.invariant)(typeof primValue !== 'object', 'object expected', TypeError);
42
+ invariant(typeof primValue !== 'object', 'object expected', TypeError);
69
43
  return ToNumber(primValue);
70
44
  }
71
45
  /**
@@ -75,7 +49,7 @@ function ToNumber(arg) {
75
49
  function ToInteger(n) {
76
50
  var number = ToNumber(n);
77
51
  if (number.isNaN() || number.isZero()) {
78
- return constants_1.ZERO;
52
+ return ZERO;
79
53
  }
80
54
  if (number.isFinite()) {
81
55
  return number;
@@ -90,12 +64,12 @@ function ToInteger(n) {
90
64
  * https://tc39.es/ecma262/#sec-timeclip
91
65
  * @param time
92
66
  */
93
- function TimeClip(time) {
67
+ export function TimeClip(time) {
94
68
  if (!time.isFinite()) {
95
- return new decimal_js_1.Decimal(NaN);
69
+ return new Decimal(NaN);
96
70
  }
97
71
  if (time.abs().greaterThan(8.64 * 1e15)) {
98
- return new decimal_js_1.Decimal(NaN);
72
+ return new Decimal(NaN);
99
73
  }
100
74
  return ToInteger(time);
101
75
  }
@@ -103,7 +77,7 @@ function TimeClip(time) {
103
77
  * https://tc39.es/ecma262/#sec-toobject
104
78
  * @param arg
105
79
  */
106
- function ToObject(arg) {
80
+ export function ToObject(arg) {
107
81
  if (arg == null) {
108
82
  throw new TypeError('undefined/null cannot be converted to object');
109
83
  }
@@ -114,7 +88,7 @@ function ToObject(arg) {
114
88
  * @param x
115
89
  * @param y
116
90
  */
117
- function SameValue(x, y) {
91
+ export function SameValue(x, y) {
118
92
  if (Object.is) {
119
93
  return Object.is(x, y);
120
94
  }
@@ -131,22 +105,22 @@ function SameValue(x, y) {
131
105
  * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-arraycreate
132
106
  * @param len
133
107
  */
134
- function ArrayCreate(len) {
135
- return new Array(len);
108
+ export function ArrayCreate(len) {
109
+ return Array.from({ length: len });
136
110
  }
137
111
  /**
138
112
  * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-hasownproperty
139
113
  * @param o
140
114
  * @param prop
141
115
  */
142
- function HasOwnProperty(o, prop) {
116
+ export function HasOwnProperty(o, prop) {
143
117
  return Object.prototype.hasOwnProperty.call(o, prop);
144
118
  }
145
119
  /**
146
120
  * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-type
147
121
  * @param x
148
122
  */
149
- function Type(x) {
123
+ export function Type(x) {
150
124
  if (x === null) {
151
125
  return 'Null';
152
126
  }
@@ -186,21 +160,21 @@ function mod(x, y) {
186
160
  * https://tc39.es/ecma262/#eqn-Day
187
161
  * @param t
188
162
  */
189
- function Day(t) {
163
+ export function Day(t) {
190
164
  return Math.floor(t / MS_PER_DAY);
191
165
  }
192
166
  /**
193
167
  * https://tc39.es/ecma262/#sec-week-day
194
168
  * @param t
195
169
  */
196
- function WeekDay(t) {
170
+ export function WeekDay(t) {
197
171
  return mod(Day(t) + 4, 7);
198
172
  }
199
173
  /**
200
174
  * https://tc39.es/ecma262/#sec-year-number
201
175
  * @param y
202
176
  */
203
- function DayFromYear(y) {
177
+ export function DayFromYear(y) {
204
178
  if (y < 100) {
205
179
  // Date.UTC parses 0 - 99 as 1900 - 1999
206
180
  var date = new Date(0);
@@ -214,17 +188,17 @@ function DayFromYear(y) {
214
188
  * https://tc39.es/ecma262/#sec-year-number
215
189
  * @param y
216
190
  */
217
- function TimeFromYear(y) {
191
+ export function TimeFromYear(y) {
218
192
  return Date.UTC(y, 0);
219
193
  }
220
194
  /**
221
195
  * https://tc39.es/ecma262/#sec-year-number
222
196
  * @param t
223
197
  */
224
- function YearFromTime(t) {
198
+ export function YearFromTime(t) {
225
199
  return new Date(t).getUTCFullYear();
226
200
  }
227
- function DaysInYear(y) {
201
+ export function DaysInYear(y) {
228
202
  if (y % 4 !== 0) {
229
203
  return 365;
230
204
  }
@@ -236,17 +210,17 @@ function DaysInYear(y) {
236
210
  }
237
211
  return 366;
238
212
  }
239
- function DayWithinYear(t) {
213
+ export function DayWithinYear(t) {
240
214
  return Day(t) - DayFromYear(YearFromTime(t));
241
215
  }
242
- function InLeapYear(t) {
216
+ export function InLeapYear(t) {
243
217
  return DaysInYear(YearFromTime(t)) === 365 ? 0 : 1;
244
218
  }
245
219
  /**
246
220
  * https://tc39.es/ecma262/#sec-month-number
247
221
  * @param t
248
222
  */
249
- function MonthFromTime(t) {
223
+ export function MonthFromTime(t) {
250
224
  var dwy = DayWithinYear(t);
251
225
  var leap = InLeapYear(t);
252
226
  if (dwy >= 0 && dwy < 31) {
@@ -287,7 +261,7 @@ function MonthFromTime(t) {
287
261
  }
288
262
  throw new Error('Invalid time');
289
263
  }
290
- function DateFromTime(t) {
264
+ export function DateFromTime(t) {
291
265
  var dwy = DayWithinYear(t);
292
266
  var mft = MonthFromTime(t);
293
267
  var leap = InLeapYear(t);
@@ -335,13 +309,13 @@ var SECONDS_PER_MINUTE = 60;
335
309
  var MS_PER_SECOND = 1e3;
336
310
  var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
337
311
  var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
338
- function HourFromTime(t) {
312
+ export function HourFromTime(t) {
339
313
  return mod(Math.floor(t / MS_PER_HOUR), HOURS_PER_DAY);
340
314
  }
341
- function MinFromTime(t) {
315
+ export function MinFromTime(t) {
342
316
  return mod(Math.floor(t / MS_PER_MINUTE), MINUTES_PER_HOUR);
343
317
  }
344
- function SecFromTime(t) {
318
+ export function SecFromTime(t) {
345
319
  return mod(Math.floor(t / MS_PER_SECOND), SECONDS_PER_MINUTE);
346
320
  }
347
321
  function IsCallable(fn) {
@@ -356,7 +330,7 @@ function IsCallable(fn) {
356
330
  * @param O object
357
331
  * @param internalSlots internalSlots
358
332
  */
359
- function OrdinaryHasInstance(C, O, internalSlots) {
333
+ export function OrdinaryHasInstance(C, O, internalSlots) {
360
334
  if (!IsCallable(C)) {
361
335
  return false;
362
336
  }
@@ -373,7 +347,7 @@ function OrdinaryHasInstance(C, O, internalSlots) {
373
347
  }
374
348
  return Object.prototype.isPrototypeOf.call(P, O);
375
349
  }
376
- function msFromTime(t) {
350
+ export function msFromTime(t) {
377
351
  return mod(t, MS_PER_SECOND);
378
352
  }
379
353
  function OrdinaryToPrimitive(O, hint) {
@@ -396,7 +370,7 @@ function OrdinaryToPrimitive(O, hint) {
396
370
  }
397
371
  throw new TypeError('Cannot convert object to primitive value');
398
372
  }
399
- function ToPrimitive(input, preferredType) {
373
+ export function ToPrimitive(input, preferredType) {
400
374
  if (typeof input === 'object' && input != null) {
401
375
  var exoticToPrim = Symbol.toPrimitive in input ? input[Symbol.toPrimitive] : undefined;
402
376
  var hint = void 0;
@@ -408,7 +382,7 @@ function ToPrimitive(input, preferredType) {
408
382
  hint = 'string';
409
383
  }
410
384
  else {
411
- (0, utils_1.invariant)(preferredType === 'number', 'preferredType must be "string" or "number"');
385
+ invariant(preferredType === 'number', 'preferredType must be "string" or "number"');
412
386
  hint = 'number';
413
387
  }
414
388
  var result = exoticToPrim.call(input, hint);
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CanonicalizeLocaleList = CanonicalizeLocaleList;
4
1
  /**
5
2
  * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
6
3
  * @param locales
7
4
  */
8
- function CanonicalizeLocaleList(locales) {
5
+ export function CanonicalizeLocaleList(locales) {
9
6
  // TODO
10
7
  return Intl.getCanonicalLocales(locales);
11
8
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CanonicalizeTimeZoneName = CanonicalizeTimeZoneName;
4
1
  /**
5
2
  * https://tc39.es/ecma402/#sec-canonicalizetimezonename
6
3
  * @param tz
7
4
  */
8
- function CanonicalizeTimeZoneName(tz, _a) {
5
+ export function CanonicalizeTimeZoneName(tz, _a) {
9
6
  var zoneNames = _a.zoneNames, uppercaseLinks = _a.uppercaseLinks;
10
7
  var uppercasedTz = tz.toUpperCase();
11
8
  var uppercasedZones = zoneNames.reduce(function (all, z) {
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CoerceOptionsToObject = CoerceOptionsToObject;
4
- var _262_1 = require("./262");
1
+ import { ToObject } from './262.js';
5
2
  /**
6
3
  * https://tc39.es/ecma402/#sec-coerceoptionstoobject
7
4
  * @param options
8
5
  * @returns
9
6
  */
10
- function CoerceOptionsToObject(options) {
7
+ export function CoerceOptionsToObject(options) {
11
8
  if (typeof options === 'undefined') {
12
9
  return Object.create(null);
13
10
  }
14
- return (0, _262_1.ToObject)(options);
11
+ return ToObject(options);
15
12
  }
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultNumberOption = DefaultNumberOption;
4
1
  /**
5
2
  * https://tc39.es/ecma402/#sec-defaultnumberoption
6
3
  * @param val
@@ -8,7 +5,7 @@ exports.DefaultNumberOption = DefaultNumberOption;
8
5
  * @param max
9
6
  * @param fallback
10
7
  */
11
- function DefaultNumberOption(inputVal, min, max, fallback) {
8
+ export function DefaultNumberOption(inputVal, min, max, fallback) {
12
9
  if (inputVal === undefined) {
13
10
  // @ts-expect-error
14
11
  return fallback;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * https://tc39.es/ecma402/#sec-getnumberoption
4
3
  * @param options
@@ -7,10 +6,8 @@
7
6
  * @param max
8
7
  * @param fallback
9
8
  */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.GetNumberOption = GetNumberOption;
12
- var DefaultNumberOption_1 = require("./DefaultNumberOption");
13
- function GetNumberOption(options, property, minimum, maximum, fallback) {
9
+ import { DefaultNumberOption } from './DefaultNumberOption.js';
10
+ export function GetNumberOption(options, property, minimum, maximum, fallback) {
14
11
  var val = options[property];
15
- return (0, DefaultNumberOption_1.DefaultNumberOption)(val, minimum, maximum, fallback);
12
+ return DefaultNumberOption(val, minimum, maximum, fallback);
16
13
  }
package/GetOption.js CHANGED
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetOption = GetOption;
4
- var _262_1 = require("./262");
1
+ import { ToString } from './262.js';
5
2
  /**
6
3
  * https://tc39.es/ecma402/#sec-getoption
7
4
  * @param opts
@@ -10,7 +7,7 @@ var _262_1 = require("./262");
10
7
  * @param values
11
8
  * @param fallback
12
9
  */
13
- function GetOption(opts, prop, type, values, fallback) {
10
+ export function GetOption(opts, prop, type, values, fallback) {
14
11
  if (typeof opts !== 'object') {
15
12
  throw new TypeError('Options must be an object');
16
13
  }
@@ -23,7 +20,7 @@ function GetOption(opts, prop, type, values, fallback) {
23
20
  value = Boolean(value);
24
21
  }
25
22
  if (type === 'string') {
26
- value = (0, _262_1.ToString)(value);
23
+ value = ToString(value);
27
24
  }
28
25
  if (values !== undefined && !values.filter(function (val) { return val == value; }).length) {
29
26
  throw new RangeError("".concat(value, " is not within ").concat(values.join(', ')));
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetOptionsObject = GetOptionsObject;
4
1
  /**
5
2
  * https://tc39.es/ecma402/#sec-getoptionsobject
6
3
  * @param options
7
4
  * @returns
8
5
  */
9
- function GetOptionsObject(options) {
6
+ export function GetOptionsObject(options) {
10
7
  if (typeof options === 'undefined') {
11
8
  return Object.create(null);
12
9
  }
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /**
3
2
  * https://tc39.es/ecma402/#sec-getstringorbooleanoption
4
3
  * @param opts
@@ -8,10 +7,8 @@
8
7
  * @param falsyValue
9
8
  * @param fallback
10
9
  */
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.GetStringOrBooleanOption = GetStringOrBooleanOption;
13
- var _262_1 = require("./262");
14
- function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyValue, fallback) {
10
+ import { ToString } from './262.js';
11
+ export function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyValue, fallback) {
15
12
  var value = opts[prop];
16
13
  if (value === undefined) {
17
14
  return fallback;
@@ -23,7 +20,7 @@ function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyValue, fal
23
20
  if (valueBoolean === false) {
24
21
  return falsyValue;
25
22
  }
26
- value = (0, _262_1.ToString)(value);
23
+ value = ToString(value);
27
24
  if (value === 'true' || value === 'false') {
28
25
  return fallback;
29
26
  }
@@ -1,12 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SIMPLE_UNITS = exports.SANCTIONED_UNITS = void 0;
4
- exports.removeUnitNamespace = removeUnitNamespace;
5
- exports.IsSanctionedSimpleUnitIdentifier = IsSanctionedSimpleUnitIdentifier;
6
1
  /**
7
2
  * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
8
3
  */
9
- exports.SANCTIONED_UNITS = [
4
+ export var SANCTIONED_UNITS = [
10
5
  'angle-degree',
11
6
  'area-acre',
12
7
  'area-hectare',
@@ -53,16 +48,16 @@ exports.SANCTIONED_UNITS = [
53
48
  ];
54
49
  // In CLDR, the unit name always follows the form `namespace-unit` pattern.
55
50
  // For example: `digital-bit` instead of `bit`. This function removes the namespace prefix.
56
- function removeUnitNamespace(unit) {
51
+ export function removeUnitNamespace(unit) {
57
52
  return unit.slice(unit.indexOf('-') + 1);
58
53
  }
59
54
  /**
60
55
  * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
61
56
  */
62
- exports.SIMPLE_UNITS = exports.SANCTIONED_UNITS.map(removeUnitNamespace);
57
+ export var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
63
58
  /**
64
59
  * https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
65
60
  */
66
- function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
67
- return exports.SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
61
+ export function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
62
+ return SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
68
63
  }
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IsValidTimeZoneName = IsValidTimeZoneName;
4
1
  /**
5
2
  * https://tc39.es/ecma402/#sec-isvalidtimezonename
6
3
  * @param tz
7
4
  * @param implDetails implementation details
8
5
  */
9
- function IsValidTimeZoneName(tz, _a) {
6
+ export function IsValidTimeZoneName(tz, _a) {
10
7
  var zoneNamesFromData = _a.zoneNamesFromData, uppercaseLinks = _a.uppercaseLinks;
11
8
  var uppercasedTz = tz.toUpperCase();
12
9
  var zoneNames = new Set();
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IsWellFormedCurrencyCode = IsWellFormedCurrencyCode;
4
1
  /**
5
2
  * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
6
3
  * @param str string to convert
@@ -12,7 +9,7 @@ var NOT_A_Z_REGEX = /[^A-Z]/;
12
9
  /**
13
10
  * https://tc39.es/ecma402/#sec-iswellformedcurrencycode
14
11
  */
15
- function IsWellFormedCurrencyCode(currency) {
12
+ export function IsWellFormedCurrencyCode(currency) {
16
13
  currency = toUpperCase(currency);
17
14
  if (currency.length !== 3) {
18
15
  return false;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IsWellFormedUnitIdentifier = IsWellFormedUnitIdentifier;
4
- var IsSanctionedSimpleUnitIdentifier_1 = require("./IsSanctionedSimpleUnitIdentifier");
1
+ import { IsSanctionedSimpleUnitIdentifier } from './IsSanctionedSimpleUnitIdentifier.js';
5
2
  /**
6
3
  * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
7
4
  * @param str string to convert
@@ -13,9 +10,9 @@ function toLowerCase(str) {
13
10
  * https://tc39.es/ecma402/#sec-iswellformedunitidentifier
14
11
  * @param unit
15
12
  */
16
- function IsWellFormedUnitIdentifier(unit) {
13
+ export function IsWellFormedUnitIdentifier(unit) {
17
14
  unit = toLowerCase(unit);
18
- if ((0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(unit)) {
15
+ if (IsSanctionedSimpleUnitIdentifier(unit)) {
19
16
  return true;
20
17
  }
21
18
  var units = unit.split('-per-');
@@ -23,8 +20,8 @@ function IsWellFormedUnitIdentifier(unit) {
23
20
  return false;
24
21
  }
25
22
  var numerator = units[0], denominator = units[1];
26
- if (!(0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(numerator) ||
27
- !(0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(denominator)) {
23
+ if (!IsSanctionedSimpleUnitIdentifier(numerator) ||
24
+ !IsSanctionedSimpleUnitIdentifier(denominator)) {
28
25
  return false;
29
26
  }
30
27
  return true;
@@ -1,3 +1,3 @@
1
- import Decimal from 'decimal.js';
2
- import { UnsignedRoundingModeType } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { UnsignedRoundingModeType } from '../types/number.js';
3
3
  export declare function ApplyUnsignedRoundingMode(x: Decimal, r1: Decimal, r2: Decimal, unsignedRoundingMode: UnsignedRoundingModeType): Decimal;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApplyUnsignedRoundingMode = ApplyUnsignedRoundingMode;
4
- var utils_1 = require("../utils");
5
- function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
1
+ import { invariant } from '../utils.js';
2
+ export function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
6
3
  if (x.eq(r1))
7
4
  return r1;
8
- (0, utils_1.invariant)(r1.lessThan(x) && x.lessThan(r2), "x should be between r1 and r2 but x=".concat(x, ", r1=").concat(r1, ", r2=").concat(r2));
5
+ invariant(r1.lessThan(x) && x.lessThan(r2), "x should be between r1 and r2 but x=".concat(x, ", r1=").concat(r1, ", r2=").concat(r2));
9
6
  if (unsignedRoundingMode === 'zero') {
10
7
  return r1;
11
8
  }
@@ -20,14 +17,14 @@ function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
20
17
  if (d2.lessThan(d1)) {
21
18
  return r2;
22
19
  }
23
- (0, utils_1.invariant)(d1.eq(d2), 'd1 should be equal to d2');
20
+ invariant(d1.eq(d2), 'd1 should be equal to d2');
24
21
  if (unsignedRoundingMode === 'half-zero') {
25
22
  return r1;
26
23
  }
27
24
  if (unsignedRoundingMode === 'half-infinity') {
28
25
  return r2;
29
26
  }
30
- (0, utils_1.invariant)(unsignedRoundingMode === 'half-even', 'unsignedRoundingMode should be half-even');
27
+ invariant(unsignedRoundingMode === 'half-even', 'unsignedRoundingMode should be half-even');
31
28
  var cardinality = r1.div(r2.minus(r1)).mod(2);
32
29
  if (cardinality.isZero()) {
33
30
  return r1;
@@ -1,4 +1,4 @@
1
- import { NumberFormatInternal, NumberFormatPart } from '../types/number';
1
+ import { NumberFormatInternal, NumberFormatPart } from '../types/number.js';
2
2
  /**
3
3
  * https://tc39.es/ecma402/#sec-collapsenumberrange
4
4
  * LDML: https://unicode-org.github.io/cldr/ldml/tr35-numbers.html#collapsing-number-ranges
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CollapseNumberRange = CollapseNumberRange;
4
1
  var PART_TYPES_TO_COLLAPSE = new Set([
5
2
  'unit',
6
3
  'exponentMinusSign',
@@ -17,7 +14,7 @@ var PART_TYPES_TO_COLLAPSE = new Set([
17
14
  * https://tc39.es/ecma402/#sec-collapsenumberrange
18
15
  * LDML: https://unicode-org.github.io/cldr/ldml/tr35-numbers.html#collapsing-number-ranges
19
16
  */
20
- function CollapseNumberRange(numberFormat, result, _a) {
17
+ export function CollapseNumberRange(numberFormat, result, _a) {
21
18
  var getInternalSlots = _a.getInternalSlots;
22
19
  var internalSlots = getInternalSlots(numberFormat);
23
20
  var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
@@ -1,5 +1,5 @@
1
- import Decimal from 'decimal.js';
2
- import { NumberFormatInternal } from '../types/number';
1
+ import { Decimal } from 'decimal.js';
2
+ import { NumberFormatInternal } from '../types/number.js';
3
3
  /**
4
4
  * The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
5
5
  * according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
@@ -1,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComputeExponent = ComputeExponent;
4
- var tslib_1 = require("tslib");
5
- var decimal_js_1 = tslib_1.__importDefault(require("decimal.js"));
6
- var ComputeExponentForMagnitude_1 = require("./ComputeExponentForMagnitude");
7
- var FormatNumericToString_1 = require("./FormatNumericToString");
1
+ import { Decimal } from 'decimal.js';
2
+ import { ComputeExponentForMagnitude } from './ComputeExponentForMagnitude.js';
3
+ import { FormatNumericToString } from './FormatNumericToString.js';
8
4
  /**
9
5
  * The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
10
6
  * according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
@@ -12,7 +8,7 @@ var FormatNumericToString_1 = require("./FormatNumericToString");
12
8
  *
13
9
  * NOT IN SPEC: it returns [exponent, magnitude].
14
10
  */
15
- function ComputeExponent(internalSlots, x) {
11
+ export function ComputeExponent(internalSlots, x) {
16
12
  if (x.isZero()) {
17
13
  return [0, 0];
18
14
  }
@@ -20,10 +16,10 @@ function ComputeExponent(internalSlots, x) {
20
16
  x = x.negated();
21
17
  }
22
18
  var magnitude = x.log(10).floor();
23
- var exponent = (0, ComputeExponentForMagnitude_1.ComputeExponentForMagnitude)(internalSlots, magnitude);
19
+ var exponent = ComputeExponentForMagnitude(internalSlots, magnitude);
24
20
  // Preserve more precision by doing multiplication when exponent is negative.
25
- x = x.times(decimal_js_1.default.pow(10, -exponent));
26
- var formatNumberResult = (0, FormatNumericToString_1.FormatNumericToString)(internalSlots, x);
21
+ x = x.times(Decimal.pow(10, -exponent));
22
+ var formatNumberResult = FormatNumericToString(internalSlots, x);
27
23
  if (formatNumberResult.roundedNumber.isZero()) {
28
24
  return [exponent, magnitude.toNumber()];
29
25
  }
@@ -32,7 +28,7 @@ function ComputeExponent(internalSlots, x) {
32
28
  return [exponent, magnitude.toNumber()];
33
29
  }
34
30
  return [
35
- (0, ComputeExponentForMagnitude_1.ComputeExponentForMagnitude)(internalSlots, magnitude.plus(1)),
31
+ ComputeExponentForMagnitude(internalSlots, magnitude.plus(1)),
36
32
  magnitude.plus(1).toNumber(),
37
33
  ];
38
34
  }