@formatjs/ecma402-abstract 1.17.2 → 1.17.3

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 (144) hide show
  1. package/NumberFormat/InitializeNumberFormat.d.ts +1 -1
  2. package/NumberFormat/InitializeNumberFormat.js +7 -7
  3. package/SupportedLocales.js +3 -3
  4. package/lib/262.js +49 -23
  5. package/lib/CanonicalizeLocaleList.js +5 -1
  6. package/lib/CanonicalizeTimeZoneName.js +5 -1
  7. package/lib/CoerceOptionsToObject.js +7 -3
  8. package/lib/DefaultNumberOption.js +5 -1
  9. package/lib/GetNumberOption.js +7 -3
  10. package/lib/GetOption.js +7 -3
  11. package/lib/GetOptionsObject.js +5 -1
  12. package/lib/GetStringOrBooleanOption.js +7 -3
  13. package/lib/IsSanctionedSimpleUnitIdentifier.js +10 -5
  14. package/lib/IsValidTimeZoneName.js +5 -1
  15. package/lib/IsWellFormedCurrencyCode.js +5 -1
  16. package/lib/IsWellFormedUnitIdentifier.js +9 -5
  17. package/lib/NumberFormat/ApplyUnsignedRoundingMode.js +5 -1
  18. package/lib/NumberFormat/CollapseNumberRange.js +5 -1
  19. package/lib/NumberFormat/ComputeExponent.js +13 -9
  20. package/lib/NumberFormat/ComputeExponentForMagnitude.js +5 -1
  21. package/lib/NumberFormat/CurrencyDigits.js +7 -3
  22. package/lib/NumberFormat/FormatApproximately.js +5 -1
  23. package/lib/NumberFormat/FormatNumericRange.js +7 -3
  24. package/lib/NumberFormat/FormatNumericRangeToParts.js +7 -3
  25. package/lib/NumberFormat/FormatNumericToParts.js +9 -5
  26. package/lib/NumberFormat/FormatNumericToString.js +15 -11
  27. package/lib/NumberFormat/GetUnsignedRoundingMode.js +5 -1
  28. package/lib/NumberFormat/InitializeNumberFormat.d.ts +1 -1
  29. package/lib/NumberFormat/InitializeNumberFormat.js +31 -27
  30. package/lib/NumberFormat/PartitionNumberPattern.js +16 -11
  31. package/lib/NumberFormat/PartitionNumberRangePattern.js +12 -8
  32. package/lib/NumberFormat/SetNumberFormatDigitOptions.js +14 -10
  33. package/lib/NumberFormat/SetNumberFormatUnitOptions.js +16 -12
  34. package/lib/NumberFormat/ToRawFixed.js +8 -4
  35. package/lib/NumberFormat/ToRawPrecision.js +11 -7
  36. package/lib/NumberFormat/digit-mapping.generated.js +4 -1
  37. package/lib/NumberFormat/format_to_parts.js +11 -8
  38. package/lib/PartitionPattern.js +7 -3
  39. package/lib/SupportedLocales.js +12 -8
  40. package/lib/data.js +7 -3
  41. package/lib/index.js +56 -42
  42. package/lib/regex.generated.js +4 -1
  43. package/lib/types/core.js +2 -1
  44. package/lib/types/date-time.js +5 -2
  45. package/lib/types/displaynames.js +2 -1
  46. package/lib/types/list.js +2 -1
  47. package/lib/types/number.js +2 -1
  48. package/lib/types/plural-rules.js +2 -1
  49. package/lib/types/relative-time.js +2 -1
  50. package/lib/utils.js +22 -10
  51. package/package.json +3 -3
  52. package/types/date-time.js +1 -1
  53. package/262.d.ts.map +0 -1
  54. package/CanonicalizeLocaleList.d.ts.map +0 -1
  55. package/CanonicalizeTimeZoneName.d.ts.map +0 -1
  56. package/CoerceOptionsToObject.d.ts.map +0 -1
  57. package/DefaultNumberOption.d.ts.map +0 -1
  58. package/GetNumberOption.d.ts.map +0 -1
  59. package/GetOption.d.ts.map +0 -1
  60. package/GetOptionsObject.d.ts.map +0 -1
  61. package/GetStringOrBooleanOption.d.ts.map +0 -1
  62. package/IsSanctionedSimpleUnitIdentifier.d.ts.map +0 -1
  63. package/IsValidTimeZoneName.d.ts.map +0 -1
  64. package/IsWellFormedCurrencyCode.d.ts.map +0 -1
  65. package/IsWellFormedUnitIdentifier.d.ts.map +0 -1
  66. package/NumberFormat/ApplyUnsignedRoundingMode.d.ts.map +0 -1
  67. package/NumberFormat/CollapseNumberRange.d.ts.map +0 -1
  68. package/NumberFormat/ComputeExponent.d.ts.map +0 -1
  69. package/NumberFormat/ComputeExponentForMagnitude.d.ts.map +0 -1
  70. package/NumberFormat/CurrencyDigits.d.ts.map +0 -1
  71. package/NumberFormat/FormatApproximately.d.ts.map +0 -1
  72. package/NumberFormat/FormatNumericRange.d.ts.map +0 -1
  73. package/NumberFormat/FormatNumericRangeToParts.d.ts.map +0 -1
  74. package/NumberFormat/FormatNumericToParts.d.ts.map +0 -1
  75. package/NumberFormat/FormatNumericToString.d.ts.map +0 -1
  76. package/NumberFormat/GetUnsignedRoundingMode.d.ts.map +0 -1
  77. package/NumberFormat/InitializeNumberFormat.d.ts.map +0 -1
  78. package/NumberFormat/PartitionNumberPattern.d.ts.map +0 -1
  79. package/NumberFormat/PartitionNumberRangePattern.d.ts.map +0 -1
  80. package/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +0 -1
  81. package/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +0 -1
  82. package/NumberFormat/ToRawFixed.d.ts.map +0 -1
  83. package/NumberFormat/ToRawPrecision.d.ts.map +0 -1
  84. package/NumberFormat/digit-mapping.generated.d.ts.map +0 -1
  85. package/NumberFormat/format_to_parts.d.ts.map +0 -1
  86. package/PartitionPattern.d.ts.map +0 -1
  87. package/SupportedLocales.d.ts.map +0 -1
  88. package/data.d.ts.map +0 -1
  89. package/index.d.ts.map +0 -1
  90. package/lib/262.d.ts.map +0 -1
  91. package/lib/CanonicalizeLocaleList.d.ts.map +0 -1
  92. package/lib/CanonicalizeTimeZoneName.d.ts.map +0 -1
  93. package/lib/CoerceOptionsToObject.d.ts.map +0 -1
  94. package/lib/DefaultNumberOption.d.ts.map +0 -1
  95. package/lib/GetNumberOption.d.ts.map +0 -1
  96. package/lib/GetOption.d.ts.map +0 -1
  97. package/lib/GetOptionsObject.d.ts.map +0 -1
  98. package/lib/GetStringOrBooleanOption.d.ts.map +0 -1
  99. package/lib/IsSanctionedSimpleUnitIdentifier.d.ts.map +0 -1
  100. package/lib/IsValidTimeZoneName.d.ts.map +0 -1
  101. package/lib/IsWellFormedCurrencyCode.d.ts.map +0 -1
  102. package/lib/IsWellFormedUnitIdentifier.d.ts.map +0 -1
  103. package/lib/NumberFormat/ApplyUnsignedRoundingMode.d.ts.map +0 -1
  104. package/lib/NumberFormat/CollapseNumberRange.d.ts.map +0 -1
  105. package/lib/NumberFormat/ComputeExponent.d.ts.map +0 -1
  106. package/lib/NumberFormat/ComputeExponentForMagnitude.d.ts.map +0 -1
  107. package/lib/NumberFormat/CurrencyDigits.d.ts.map +0 -1
  108. package/lib/NumberFormat/FormatApproximately.d.ts.map +0 -1
  109. package/lib/NumberFormat/FormatNumericRange.d.ts.map +0 -1
  110. package/lib/NumberFormat/FormatNumericRangeToParts.d.ts.map +0 -1
  111. package/lib/NumberFormat/FormatNumericToParts.d.ts.map +0 -1
  112. package/lib/NumberFormat/FormatNumericToString.d.ts.map +0 -1
  113. package/lib/NumberFormat/GetUnsignedRoundingMode.d.ts.map +0 -1
  114. package/lib/NumberFormat/InitializeNumberFormat.d.ts.map +0 -1
  115. package/lib/NumberFormat/PartitionNumberPattern.d.ts.map +0 -1
  116. package/lib/NumberFormat/PartitionNumberRangePattern.d.ts.map +0 -1
  117. package/lib/NumberFormat/SetNumberFormatDigitOptions.d.ts.map +0 -1
  118. package/lib/NumberFormat/SetNumberFormatUnitOptions.d.ts.map +0 -1
  119. package/lib/NumberFormat/ToRawFixed.d.ts.map +0 -1
  120. package/lib/NumberFormat/ToRawPrecision.d.ts.map +0 -1
  121. package/lib/NumberFormat/digit-mapping.generated.d.ts.map +0 -1
  122. package/lib/NumberFormat/format_to_parts.d.ts.map +0 -1
  123. package/lib/PartitionPattern.d.ts.map +0 -1
  124. package/lib/SupportedLocales.d.ts.map +0 -1
  125. package/lib/data.d.ts.map +0 -1
  126. package/lib/index.d.ts.map +0 -1
  127. package/lib/regex.generated.d.ts.map +0 -1
  128. package/lib/types/core.d.ts.map +0 -1
  129. package/lib/types/date-time.d.ts.map +0 -1
  130. package/lib/types/displaynames.d.ts.map +0 -1
  131. package/lib/types/list.d.ts.map +0 -1
  132. package/lib/types/number.d.ts.map +0 -1
  133. package/lib/types/plural-rules.d.ts.map +0 -1
  134. package/lib/types/relative-time.d.ts.map +0 -1
  135. package/lib/utils.d.ts.map +0 -1
  136. package/regex.generated.d.ts.map +0 -1
  137. package/types/core.d.ts.map +0 -1
  138. package/types/date-time.d.ts.map +0 -1
  139. package/types/displaynames.d.ts.map +0 -1
  140. package/types/list.d.ts.map +0 -1
  141. package/types/number.d.ts.map +0 -1
  142. package/types/plural-rules.d.ts.map +0 -1
  143. package/types/relative-time.d.ts.map +0 -1
  144. package/utils.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { NumberFormatInternal, NumberFormatOptions, NumberFormatLocaleInternalData } from '../types/number';
1
+ import { NumberFormatInternal, NumberFormatLocaleInternalData, NumberFormatOptions } from '../types/number';
2
2
  /**
3
3
  * https://tc39.es/ecma402/#sec-initializenumberformat
4
4
  */
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InitializeNumberFormat = void 0;
4
- var CanonicalizeLocaleList_1 = require("../CanonicalizeLocaleList");
5
- var GetOption_1 = require("../GetOption");
6
4
  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");
5
+ var CanonicalizeLocaleList_1 = require("../CanonicalizeLocaleList");
11
6
  var CoerceOptionsToObject_1 = require("../CoerceOptionsToObject");
12
7
  var GetNumberOption_1 = require("../GetNumberOption");
8
+ var GetOption_1 = require("../GetOption");
13
9
  var GetStringOrBooleanOption_1 = require("../GetStringOrBooleanOption");
10
+ var utils_1 = require("../utils");
11
+ var CurrencyDigits_1 = require("./CurrencyDigits");
12
+ var SetNumberFormatDigitOptions_1 = require("./SetNumberFormatDigitOptions");
13
+ var SetNumberFormatUnitOptions_1 = require("./SetNumberFormatUnitOptions");
14
14
  var VALID_ROUND_INCREMENT_VALUES = [
15
15
  1, 2, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1000, 2000,
16
16
  ];
@@ -33,7 +33,7 @@ function InitializeNumberFormat(nf, locales, opts, _a) {
33
33
  throw RangeError("Invalid numberingSystems: ".concat(numberingSystem));
34
34
  }
35
35
  opt.nu = numberingSystem;
36
- var r = (0, intl_localematcher_1.ResolveLocale)(availableLocales, requestedLocales, opt,
36
+ var r = (0, intl_localematcher_1.ResolveLocale)(Array.from(availableLocales), requestedLocales, opt,
37
37
  // [[RelevantExtensionKeys]] slot, which is a constant
38
38
  ['nu'], localeData, getDefaultLocale);
39
39
  var dataLocaleData = localeData[r.dataLocale];
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SupportedLocales = void 0;
4
+ var intl_localematcher_1 = require("@formatjs/intl-localematcher");
4
5
  var _262_1 = require("./262");
5
6
  var GetOption_1 = require("./GetOption");
6
- var intl_localematcher_1 = require("@formatjs/intl-localematcher");
7
7
  /**
8
8
  * https://tc39.es/ecma402/#sec-supportedlocales
9
9
  * @param availableLocales
@@ -17,8 +17,8 @@ function SupportedLocales(availableLocales, requestedLocales, options) {
17
17
  matcher = (0, GetOption_1.GetOption)(options, 'localeMatcher', 'string', ['lookup', 'best fit'], 'best fit');
18
18
  }
19
19
  if (matcher === 'best fit') {
20
- return (0, intl_localematcher_1.LookupSupportedLocales)(availableLocales, requestedLocales);
20
+ return (0, intl_localematcher_1.LookupSupportedLocales)(Array.from(availableLocales), requestedLocales);
21
21
  }
22
- return (0, intl_localematcher_1.LookupSupportedLocales)(availableLocales, requestedLocales);
22
+ return (0, intl_localematcher_1.LookupSupportedLocales)(Array.from(availableLocales), requestedLocales);
23
23
  }
24
24
  exports.SupportedLocales = SupportedLocales;
package/lib/262.js CHANGED
@@ -1,18 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.msFromTime = exports.OrdinaryHasInstance = exports.SecFromTime = exports.MinFromTime = exports.HourFromTime = exports.DateFromTime = exports.MonthFromTime = exports.InLeapYear = exports.DayWithinYear = exports.DaysInYear = exports.YearFromTime = exports.TimeFromYear = exports.DayFromYear = exports.WeekDay = exports.Day = exports.Type = exports.HasOwnProperty = exports.ArrayCreate = exports.SameValue = exports.ToObject = exports.TimeClip = exports.ToNumber = exports.ToString = void 0;
1
4
  /**
2
5
  * https://tc39.es/ecma262/#sec-tostring
3
6
  */
4
- export function ToString(o) {
7
+ function ToString(o) {
5
8
  // Only symbol is irregular...
6
9
  if (typeof o === 'symbol') {
7
10
  throw TypeError('Cannot convert a Symbol value to a string');
8
11
  }
9
12
  return String(o);
10
13
  }
14
+ exports.ToString = ToString;
11
15
  /**
12
16
  * https://tc39.es/ecma262/#sec-tonumber
13
17
  * @param val
14
18
  */
15
- export function ToNumber(val) {
19
+ function ToNumber(val) {
16
20
  if (val === undefined) {
17
21
  return NaN;
18
22
  }
@@ -30,6 +34,7 @@ export function ToNumber(val) {
30
34
  }
31
35
  return Number(val);
32
36
  }
37
+ exports.ToNumber = ToNumber;
33
38
  /**
34
39
  * https://tc39.es/ecma262/#sec-tointeger
35
40
  * @param n
@@ -55,7 +60,7 @@ function ToInteger(n) {
55
60
  * https://tc39.es/ecma262/#sec-timeclip
56
61
  * @param time
57
62
  */
58
- export function TimeClip(time) {
63
+ function TimeClip(time) {
59
64
  if (!isFinite(time)) {
60
65
  return NaN;
61
66
  }
@@ -64,22 +69,24 @@ export function TimeClip(time) {
64
69
  }
65
70
  return ToInteger(time);
66
71
  }
72
+ exports.TimeClip = TimeClip;
67
73
  /**
68
74
  * https://tc39.es/ecma262/#sec-toobject
69
75
  * @param arg
70
76
  */
71
- export function ToObject(arg) {
77
+ function ToObject(arg) {
72
78
  if (arg == null) {
73
79
  throw new TypeError('undefined/null cannot be converted to object');
74
80
  }
75
81
  return Object(arg);
76
82
  }
83
+ exports.ToObject = ToObject;
77
84
  /**
78
85
  * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-samevalue
79
86
  * @param x
80
87
  * @param y
81
88
  */
82
- export function SameValue(x, y) {
89
+ function SameValue(x, y) {
83
90
  if (Object.is) {
84
91
  return Object.is(x, y);
85
92
  }
@@ -92,26 +99,29 @@ export function SameValue(x, y) {
92
99
  // Step 6.a: NaN == NaN
93
100
  return x !== x && y !== y;
94
101
  }
102
+ exports.SameValue = SameValue;
95
103
  /**
96
104
  * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-arraycreate
97
105
  * @param len
98
106
  */
99
- export function ArrayCreate(len) {
107
+ function ArrayCreate(len) {
100
108
  return new Array(len);
101
109
  }
110
+ exports.ArrayCreate = ArrayCreate;
102
111
  /**
103
112
  * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-hasownproperty
104
113
  * @param o
105
114
  * @param prop
106
115
  */
107
- export function HasOwnProperty(o, prop) {
116
+ function HasOwnProperty(o, prop) {
108
117
  return Object.prototype.hasOwnProperty.call(o, prop);
109
118
  }
119
+ exports.HasOwnProperty = HasOwnProperty;
110
120
  /**
111
121
  * https://www.ecma-international.org/ecma-262/11.0/index.html#sec-type
112
122
  * @param x
113
123
  */
114
- export function Type(x) {
124
+ function Type(x) {
115
125
  if (x === null) {
116
126
  return 'Null';
117
127
  }
@@ -137,6 +147,7 @@ export function Type(x) {
137
147
  return 'BigInt';
138
148
  }
139
149
  }
150
+ exports.Type = Type;
140
151
  var MS_PER_DAY = 86400000;
141
152
  /**
142
153
  * https://www.ecma-international.org/ecma-262/11.0/index.html#eqn-modulo
@@ -151,38 +162,43 @@ function mod(x, y) {
151
162
  * https://tc39.es/ecma262/#eqn-Day
152
163
  * @param t
153
164
  */
154
- export function Day(t) {
165
+ function Day(t) {
155
166
  return Math.floor(t / MS_PER_DAY);
156
167
  }
168
+ exports.Day = Day;
157
169
  /**
158
170
  * https://tc39.es/ecma262/#sec-week-day
159
171
  * @param t
160
172
  */
161
- export function WeekDay(t) {
173
+ function WeekDay(t) {
162
174
  return mod(Day(t) + 4, 7);
163
175
  }
176
+ exports.WeekDay = WeekDay;
164
177
  /**
165
178
  * https://tc39.es/ecma262/#sec-year-number
166
179
  * @param y
167
180
  */
168
- export function DayFromYear(y) {
181
+ function DayFromYear(y) {
169
182
  return Date.UTC(y, 0) / MS_PER_DAY;
170
183
  }
184
+ exports.DayFromYear = DayFromYear;
171
185
  /**
172
186
  * https://tc39.es/ecma262/#sec-year-number
173
187
  * @param y
174
188
  */
175
- export function TimeFromYear(y) {
189
+ function TimeFromYear(y) {
176
190
  return Date.UTC(y, 0);
177
191
  }
192
+ exports.TimeFromYear = TimeFromYear;
178
193
  /**
179
194
  * https://tc39.es/ecma262/#sec-year-number
180
195
  * @param t
181
196
  */
182
- export function YearFromTime(t) {
197
+ function YearFromTime(t) {
183
198
  return new Date(t).getUTCFullYear();
184
199
  }
185
- export function DaysInYear(y) {
200
+ exports.YearFromTime = YearFromTime;
201
+ function DaysInYear(y) {
186
202
  if (y % 4 !== 0) {
187
203
  return 365;
188
204
  }
@@ -194,17 +210,20 @@ export function DaysInYear(y) {
194
210
  }
195
211
  return 366;
196
212
  }
197
- export function DayWithinYear(t) {
213
+ exports.DaysInYear = DaysInYear;
214
+ function DayWithinYear(t) {
198
215
  return Day(t) - DayFromYear(YearFromTime(t));
199
216
  }
200
- export function InLeapYear(t) {
217
+ exports.DayWithinYear = DayWithinYear;
218
+ function InLeapYear(t) {
201
219
  return DaysInYear(YearFromTime(t)) === 365 ? 0 : 1;
202
220
  }
221
+ exports.InLeapYear = InLeapYear;
203
222
  /**
204
223
  * https://tc39.es/ecma262/#sec-month-number
205
224
  * @param t
206
225
  */
207
- export function MonthFromTime(t) {
226
+ function MonthFromTime(t) {
208
227
  var dwy = DayWithinYear(t);
209
228
  var leap = InLeapYear(t);
210
229
  if (dwy >= 0 && dwy < 31) {
@@ -245,7 +264,8 @@ export function MonthFromTime(t) {
245
264
  }
246
265
  throw new Error('Invalid time');
247
266
  }
248
- export function DateFromTime(t) {
267
+ exports.MonthFromTime = MonthFromTime;
268
+ function DateFromTime(t) {
249
269
  var dwy = DayWithinYear(t);
250
270
  var mft = MonthFromTime(t);
251
271
  var leap = InLeapYear(t);
@@ -287,21 +307,25 @@ export function DateFromTime(t) {
287
307
  }
288
308
  throw new Error('Invalid time');
289
309
  }
310
+ exports.DateFromTime = DateFromTime;
290
311
  var HOURS_PER_DAY = 24;
291
312
  var MINUTES_PER_HOUR = 60;
292
313
  var SECONDS_PER_MINUTE = 60;
293
314
  var MS_PER_SECOND = 1e3;
294
315
  var MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
295
316
  var MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
296
- export function HourFromTime(t) {
317
+ function HourFromTime(t) {
297
318
  return mod(Math.floor(t / MS_PER_HOUR), HOURS_PER_DAY);
298
319
  }
299
- export function MinFromTime(t) {
320
+ exports.HourFromTime = HourFromTime;
321
+ function MinFromTime(t) {
300
322
  return mod(Math.floor(t / MS_PER_MINUTE), MINUTES_PER_HOUR);
301
323
  }
302
- export function SecFromTime(t) {
324
+ exports.MinFromTime = MinFromTime;
325
+ function SecFromTime(t) {
303
326
  return mod(Math.floor(t / MS_PER_SECOND), SECONDS_PER_MINUTE);
304
327
  }
328
+ exports.SecFromTime = SecFromTime;
305
329
  function IsCallable(fn) {
306
330
  return typeof fn === 'function';
307
331
  }
@@ -314,7 +338,7 @@ function IsCallable(fn) {
314
338
  * @param O object
315
339
  * @param internalSlots internalSlots
316
340
  */
317
- export function OrdinaryHasInstance(C, O, internalSlots) {
341
+ function OrdinaryHasInstance(C, O, internalSlots) {
318
342
  if (!IsCallable(C)) {
319
343
  return false;
320
344
  }
@@ -331,6 +355,8 @@ export function OrdinaryHasInstance(C, O, internalSlots) {
331
355
  }
332
356
  return Object.prototype.isPrototypeOf.call(P, O);
333
357
  }
334
- export function msFromTime(t) {
358
+ exports.OrdinaryHasInstance = OrdinaryHasInstance;
359
+ function msFromTime(t) {
335
360
  return mod(t, MS_PER_SECOND);
336
361
  }
362
+ exports.msFromTime = msFromTime;
@@ -1,8 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CanonicalizeLocaleList = void 0;
1
4
  /**
2
5
  * http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
3
6
  * @param locales
4
7
  */
5
- export function CanonicalizeLocaleList(locales) {
8
+ function CanonicalizeLocaleList(locales) {
6
9
  // TODO
7
10
  return Intl.getCanonicalLocales(locales);
8
11
  }
12
+ exports.CanonicalizeLocaleList = CanonicalizeLocaleList;
@@ -1,8 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CanonicalizeTimeZoneName = void 0;
1
4
  /**
2
5
  * https://tc39.es/ecma402/#sec-canonicalizetimezonename
3
6
  * @param tz
4
7
  */
5
- export function CanonicalizeTimeZoneName(tz, _a) {
8
+ function CanonicalizeTimeZoneName(tz, _a) {
6
9
  var tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
7
10
  var uppercasedTz = tz.toUpperCase();
8
11
  var uppercasedZones = Object.keys(tzData).reduce(function (all, z) {
@@ -15,3 +18,4 @@ export function CanonicalizeTimeZoneName(tz, _a) {
15
18
  }
16
19
  return ianaTimeZone;
17
20
  }
21
+ exports.CanonicalizeTimeZoneName = CanonicalizeTimeZoneName;
@@ -1,12 +1,16 @@
1
- import { ToObject } from './262';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceOptionsToObject = void 0;
4
+ var _262_1 = require("./262");
2
5
  /**
3
6
  * https://tc39.es/ecma402/#sec-coerceoptionstoobject
4
7
  * @param options
5
8
  * @returns
6
9
  */
7
- export function CoerceOptionsToObject(options) {
10
+ function CoerceOptionsToObject(options) {
8
11
  if (typeof options === 'undefined') {
9
12
  return Object.create(null);
10
13
  }
11
- return ToObject(options);
14
+ return (0, _262_1.ToObject)(options);
12
15
  }
16
+ exports.CoerceOptionsToObject = CoerceOptionsToObject;
@@ -1,4 +1,7 @@
1
- export function DefaultNumberOption(val, min, max, fallback) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultNumberOption = void 0;
4
+ function DefaultNumberOption(val, min, max, fallback) {
2
5
  if (val !== undefined) {
3
6
  val = Number(val);
4
7
  if (isNaN(val) || val < min || val > max) {
@@ -8,3 +11,4 @@ export function DefaultNumberOption(val, min, max, fallback) {
8
11
  }
9
12
  return fallback;
10
13
  }
14
+ exports.DefaultNumberOption = DefaultNumberOption;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * https://tc39.es/ecma402/#sec-getnumberoption
3
4
  * @param options
@@ -6,9 +7,12 @@
6
7
  * @param max
7
8
  * @param fallback
8
9
  */
9
- import { DefaultNumberOption } from './DefaultNumberOption';
10
- export function GetNumberOption(options, property, minimum, maximum, fallback) {
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.GetNumberOption = void 0;
12
+ var DefaultNumberOption_1 = require("./DefaultNumberOption");
13
+ function GetNumberOption(options, property, minimum, maximum, fallback) {
11
14
  var val = options[property];
12
15
  // @ts-expect-error
13
- return DefaultNumberOption(val, minimum, maximum, fallback);
16
+ return (0, DefaultNumberOption_1.DefaultNumberOption)(val, minimum, maximum, fallback);
14
17
  }
18
+ exports.GetNumberOption = GetNumberOption;
package/lib/GetOption.js CHANGED
@@ -1,4 +1,7 @@
1
- import { ToString } from './262';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetOption = void 0;
4
+ var _262_1 = require("./262");
2
5
  /**
3
6
  * https://tc39.es/ecma402/#sec-getoption
4
7
  * @param opts
@@ -7,7 +10,7 @@ import { ToString } from './262';
7
10
  * @param values
8
11
  * @param fallback
9
12
  */
10
- export function GetOption(opts, prop, type, values, fallback) {
13
+ function GetOption(opts, prop, type, values, fallback) {
11
14
  if (typeof opts !== 'object') {
12
15
  throw new TypeError('Options must be an object');
13
16
  }
@@ -20,7 +23,7 @@ export function GetOption(opts, prop, type, values, fallback) {
20
23
  value = Boolean(value);
21
24
  }
22
25
  if (type === 'string') {
23
- value = ToString(value);
26
+ value = (0, _262_1.ToString)(value);
24
27
  }
25
28
  if (values !== undefined && !values.filter(function (val) { return val == value; }).length) {
26
29
  throw new RangeError("".concat(value, " is not within ").concat(values.join(', ')));
@@ -29,3 +32,4 @@ export function GetOption(opts, prop, type, values, fallback) {
29
32
  }
30
33
  return fallback;
31
34
  }
35
+ exports.GetOption = GetOption;
@@ -1,9 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetOptionsObject = void 0;
1
4
  /**
2
5
  * https://tc39.es/ecma402/#sec-getoptionsobject
3
6
  * @param options
4
7
  * @returns
5
8
  */
6
- export function GetOptionsObject(options) {
9
+ function GetOptionsObject(options) {
7
10
  if (typeof options === 'undefined') {
8
11
  return Object.create(null);
9
12
  }
@@ -12,3 +15,4 @@ export function GetOptionsObject(options) {
12
15
  }
13
16
  throw new TypeError('Options must be an object');
14
17
  }
18
+ exports.GetOptionsObject = GetOptionsObject;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * https://tc39.es/ecma402/#sec-getstringorbooleanoption
3
4
  * @param opts
@@ -7,8 +8,10 @@
7
8
  * @param falsyValue
8
9
  * @param fallback
9
10
  */
10
- import { ToString } from './262';
11
- export function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyValue, fallback) {
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GetStringOrBooleanOption = void 0;
13
+ var _262_1 = require("./262");
14
+ function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyValue, fallback) {
12
15
  var value = opts[prop];
13
16
  if (value === undefined) {
14
17
  return fallback;
@@ -20,7 +23,7 @@ export function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyVal
20
23
  if (valueBoolean === false) {
21
24
  return falsyValue;
22
25
  }
23
- value = ToString(value);
26
+ value = (0, _262_1.ToString)(value);
24
27
  if (value === 'true' || value === 'false') {
25
28
  return fallback;
26
29
  }
@@ -29,3 +32,4 @@ export function GetStringOrBooleanOption(opts, prop, values, trueValue, falsyVal
29
32
  }
30
33
  return value;
31
34
  }
35
+ exports.GetStringOrBooleanOption = GetStringOrBooleanOption;
@@ -1,7 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsSanctionedSimpleUnitIdentifier = exports.SIMPLE_UNITS = exports.removeUnitNamespace = exports.SANCTIONED_UNITS = void 0;
1
4
  /**
2
5
  * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
3
6
  */
4
- export var SANCTIONED_UNITS = [
7
+ exports.SANCTIONED_UNITS = [
5
8
  'angle-degree',
6
9
  'area-acre',
7
10
  'area-hectare',
@@ -48,16 +51,18 @@ export var SANCTIONED_UNITS = [
48
51
  ];
49
52
  // In CLDR, the unit name always follows the form `namespace-unit` pattern.
50
53
  // For example: `digital-bit` instead of `bit`. This function removes the namespace prefix.
51
- export function removeUnitNamespace(unit) {
54
+ function removeUnitNamespace(unit) {
52
55
  return unit.slice(unit.indexOf('-') + 1);
53
56
  }
57
+ exports.removeUnitNamespace = removeUnitNamespace;
54
58
  /**
55
59
  * https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers
56
60
  */
57
- export var SIMPLE_UNITS = SANCTIONED_UNITS.map(removeUnitNamespace);
61
+ exports.SIMPLE_UNITS = exports.SANCTIONED_UNITS.map(removeUnitNamespace);
58
62
  /**
59
63
  * https://tc39.es/ecma402/#sec-issanctionedsimpleunitidentifier
60
64
  */
61
- export function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
62
- return SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
65
+ function IsSanctionedSimpleUnitIdentifier(unitIdentifier) {
66
+ return exports.SIMPLE_UNITS.indexOf(unitIdentifier) > -1;
63
67
  }
68
+ exports.IsSanctionedSimpleUnitIdentifier = IsSanctionedSimpleUnitIdentifier;
@@ -1,9 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsValidTimeZoneName = void 0;
1
4
  /**
2
5
  * https://tc39.es/ecma402/#sec-isvalidtimezonename
3
6
  * @param tz
4
7
  * @param implDetails implementation details
5
8
  */
6
- export function IsValidTimeZoneName(tz, _a) {
9
+ function IsValidTimeZoneName(tz, _a) {
7
10
  var tzData = _a.tzData, uppercaseLinks = _a.uppercaseLinks;
8
11
  var uppercasedTz = tz.toUpperCase();
9
12
  var zoneNames = new Set();
@@ -17,3 +20,4 @@ export function IsValidTimeZoneName(tz, _a) {
17
20
  });
18
21
  return zoneNames.has(uppercasedTz) || linkNames.has(uppercasedTz);
19
22
  }
23
+ exports.IsValidTimeZoneName = IsValidTimeZoneName;
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsWellFormedCurrencyCode = void 0;
1
4
  /**
2
5
  * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
3
6
  * @param str string to convert
@@ -9,7 +12,7 @@ var NOT_A_Z_REGEX = /[^A-Z]/;
9
12
  /**
10
13
  * https://tc39.es/ecma402/#sec-iswellformedcurrencycode
11
14
  */
12
- export function IsWellFormedCurrencyCode(currency) {
15
+ function IsWellFormedCurrencyCode(currency) {
13
16
  currency = toUpperCase(currency);
14
17
  if (currency.length !== 3) {
15
18
  return false;
@@ -19,3 +22,4 @@ export function IsWellFormedCurrencyCode(currency) {
19
22
  }
20
23
  return true;
21
24
  }
25
+ exports.IsWellFormedCurrencyCode = IsWellFormedCurrencyCode;
@@ -1,4 +1,7 @@
1
- import { IsSanctionedSimpleUnitIdentifier } from './IsSanctionedSimpleUnitIdentifier';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsWellFormedUnitIdentifier = void 0;
4
+ var IsSanctionedSimpleUnitIdentifier_1 = require("./IsSanctionedSimpleUnitIdentifier");
2
5
  /**
3
6
  * This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
4
7
  * @param str string to convert
@@ -10,9 +13,9 @@ function toLowerCase(str) {
10
13
  * https://tc39.es/ecma402/#sec-iswellformedunitidentifier
11
14
  * @param unit
12
15
  */
13
- export function IsWellFormedUnitIdentifier(unit) {
16
+ function IsWellFormedUnitIdentifier(unit) {
14
17
  unit = toLowerCase(unit);
15
- if (IsSanctionedSimpleUnitIdentifier(unit)) {
18
+ if ((0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(unit)) {
16
19
  return true;
17
20
  }
18
21
  var units = unit.split('-per-');
@@ -20,9 +23,10 @@ export function IsWellFormedUnitIdentifier(unit) {
20
23
  return false;
21
24
  }
22
25
  var numerator = units[0], denominator = units[1];
23
- if (!IsSanctionedSimpleUnitIdentifier(numerator) ||
24
- !IsSanctionedSimpleUnitIdentifier(denominator)) {
26
+ if (!(0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(numerator) ||
27
+ !(0, IsSanctionedSimpleUnitIdentifier_1.IsSanctionedSimpleUnitIdentifier)(denominator)) {
25
28
  return false;
26
29
  }
27
30
  return true;
28
31
  }
32
+ exports.IsWellFormedUnitIdentifier = IsWellFormedUnitIdentifier;
@@ -1,4 +1,7 @@
1
- export function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApplyUnsignedRoundingMode = void 0;
4
+ function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
2
5
  if (x === r1)
3
6
  return r1;
4
7
  if (unsignedRoundingMode === undefined) {
@@ -36,3 +39,4 @@ export function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
36
39
  }
37
40
  return r2;
38
41
  }
42
+ exports.ApplyUnsignedRoundingMode = ApplyUnsignedRoundingMode;
@@ -1,6 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CollapseNumberRange = void 0;
1
4
  /**
2
5
  * https://tc39.es/ecma402/#sec-collapsenumberrange
3
6
  */
4
- export function CollapseNumberRange(result) {
7
+ function CollapseNumberRange(result) {
5
8
  return result;
6
9
  }
10
+ exports.CollapseNumberRange = CollapseNumberRange;
@@ -1,6 +1,9 @@
1
- import { getMagnitude } from '../utils';
2
- import { ComputeExponentForMagnitude } from './ComputeExponentForMagnitude';
3
- import { FormatNumericToString } from './FormatNumericToString';
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");
4
7
  /**
5
8
  * The abstract operation ComputeExponent computes an exponent (power of ten) by which to scale x
6
9
  * according to the number formatting settings. It handles cases such as 999 rounding up to 1000,
@@ -8,7 +11,7 @@ import { FormatNumericToString } from './FormatNumericToString';
8
11
  *
9
12
  * NOT IN SPEC: it returns [exponent, magnitude].
10
13
  */
11
- export function ComputeExponent(numberFormat, x, _a) {
14
+ function ComputeExponent(numberFormat, x, _a) {
12
15
  var getInternalSlots = _a.getInternalSlots;
13
16
  if (x === 0) {
14
17
  return [0, 0];
@@ -16,24 +19,25 @@ export function ComputeExponent(numberFormat, x, _a) {
16
19
  if (x < 0) {
17
20
  x = -x;
18
21
  }
19
- var magnitude = getMagnitude(x);
20
- var exponent = ComputeExponentForMagnitude(numberFormat, magnitude, {
22
+ var magnitude = (0, utils_1.getMagnitude)(x);
23
+ var exponent = (0, ComputeExponentForMagnitude_1.ComputeExponentForMagnitude)(numberFormat, magnitude, {
21
24
  getInternalSlots: getInternalSlots,
22
25
  });
23
26
  // Preserve more precision by doing multiplication when exponent is negative.
24
27
  x = exponent < 0 ? x * Math.pow(10, -exponent) : x / Math.pow(10, exponent);
25
- var formatNumberResult = FormatNumericToString(getInternalSlots(numberFormat), x);
28
+ var formatNumberResult = (0, FormatNumericToString_1.FormatNumericToString)(getInternalSlots(numberFormat), x);
26
29
  if (formatNumberResult.roundedNumber === 0) {
27
30
  return [exponent, magnitude];
28
31
  }
29
- var newMagnitude = getMagnitude(formatNumberResult.roundedNumber);
32
+ var newMagnitude = (0, utils_1.getMagnitude)(formatNumberResult.roundedNumber);
30
33
  if (newMagnitude === magnitude - exponent) {
31
34
  return [exponent, magnitude];
32
35
  }
33
36
  return [
34
- ComputeExponentForMagnitude(numberFormat, magnitude + 1, {
37
+ (0, ComputeExponentForMagnitude_1.ComputeExponentForMagnitude)(numberFormat, magnitude + 1, {
35
38
  getInternalSlots: getInternalSlots,
36
39
  }),
37
40
  magnitude + 1,
38
41
  ];
39
42
  }
43
+ exports.ComputeExponent = ComputeExponent;