@formatjs/intl-numberformat 8.15.1 → 8.15.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.
package/lib/src/core.js CHANGED
@@ -1,8 +1,6 @@
1
- import { CanonicalizeLocaleList, FormatNumericRange, FormatNumericRangeToParts, FormatNumericToParts, InitializeNumberFormat, OrdinaryHasInstance, SupportedLocales, ToNumber, createMemoizedPluralRules, defineProperty, invariant, } from '@formatjs/ecma402-abstract';
1
+ import { CanonicalizeLocaleList, FormatNumeric, FormatNumericRange, FormatNumericRangeToParts, FormatNumericToParts, InitializeNumberFormat, OrdinaryHasInstance, SupportedLocales, ToIntlMathematicalValue, createMemoizedPluralRules, defineProperty, invariant, } from '@formatjs/ecma402-abstract';
2
2
  import { currencyDigitsData } from './currency-digits.generated';
3
3
  import { numberingSystemNames } from './numbering-systems.generated';
4
- // eslint-disable-next-line import/no-cycle
5
- import Decimal from 'decimal.js';
6
4
  import getInternalSlots from './get_internal_slots';
7
5
  var RESOLVED_OPTIONS_KEYS = [
8
6
  'locale',
@@ -53,17 +51,17 @@ export var NumberFormat = function (locales, options) {
53
51
  return this;
54
52
  };
55
53
  function formatToParts(x) {
56
- return FormatNumericToParts(this, toNumeric(x), {
54
+ return FormatNumericToParts(this, ToIntlMathematicalValue(x), {
57
55
  getInternalSlots: getInternalSlots,
58
56
  });
59
57
  }
60
58
  function formatRange(start, end) {
61
- return FormatNumericRange(this, toNumeric(start), toNumeric(end), {
59
+ return FormatNumericRange(this, ToIntlMathematicalValue(start), ToIntlMathematicalValue(end), {
62
60
  getInternalSlots: getInternalSlots,
63
61
  });
64
62
  }
65
63
  function formatRangeToParts(start, end) {
66
- return FormatNumericRangeToParts(this, toNumeric(start), toNumeric(end), {
64
+ return FormatNumericRangeToParts(this, ToIntlMathematicalValue(start), ToIntlMathematicalValue(end), {
67
65
  getInternalSlots: getInternalSlots,
68
66
  });
69
67
  }
@@ -122,18 +120,11 @@ var formatDescriptor = {
122
120
  throw TypeError('Intl.NumberFormat format property accessor called on incompatible receiver');
123
121
  }
124
122
  var internalSlots = getInternalSlots(this);
125
- // eslint-disable-next-line @typescript-eslint/no-this-alias
126
- var numberFormat = this;
127
123
  var boundFormat = internalSlots.boundFormat;
128
124
  if (boundFormat === undefined) {
129
125
  // https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-number-format-functions
130
126
  boundFormat = function (value) {
131
- // TODO: check bigint
132
- var x = toNumeric(value);
133
- return numberFormat
134
- .formatToParts(x)
135
- .map(function (x) { return x.value; })
136
- .join('');
127
+ return FormatNumeric(internalSlots, ToIntlMathematicalValue(value));
137
128
  };
138
129
  try {
139
130
  // https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/format-function-name.js
@@ -211,12 +202,6 @@ NumberFormat.getDefaultLocale = function () {
211
202
  return NumberFormat.__defaultLocale;
212
203
  };
213
204
  NumberFormat.polyfilled = true;
214
- function toNumeric(val) {
215
- if (typeof val === 'bigint') {
216
- return new Decimal(val.toString());
217
- }
218
- return ToNumber(val);
219
- }
220
205
  try {
221
206
  // IE11 does not have Symbol
222
207
  if (typeof Symbol !== 'undefined') {
@@ -2,10 +2,10 @@ import { NumberFormatLocaleInternalData, NumberFormatOptions, NumberFormatPart,
2
2
  import Decimal from 'decimal.js';
3
3
  export interface NumberFormat {
4
4
  resolvedOptions(): ResolvedNumberFormatOptions;
5
- formatToParts(x: number | bigint | Decimal): NumberFormatPart[];
6
- format(x: number | bigint | Decimal): string;
7
- formatRange(start: number | bigint | Decimal, end: number | bigint | Decimal): string;
8
- formatRangeToParts(start: number | bigint | Decimal, end: number | bigint | Decimal): NumberRangeToParts[];
5
+ formatToParts(x: number | bigint | Decimal | string): NumberFormatPart[];
6
+ format(x: number | bigint | Decimal | string): string;
7
+ formatRange(start: number | bigint | Decimal | string, end: number | bigint | Decimal | string): string;
8
+ formatRangeToParts(start: number | bigint | Decimal | string, end: number | bigint | Decimal | string): NumberRangeToParts[];
9
9
  }
10
10
  export interface NumberFormatConstructor {
11
11
  new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-numberformat",
3
- "version": "8.15.1",
3
+ "version": "8.15.3",
4
4
  "description": "Ponyfill for ES2020 Intl.NumberFormat",
5
5
  "keywords": [
6
6
  "polyfill",
@@ -24,13 +24,13 @@
24
24
  "dependencies": {
25
25
  "decimal.js": "10",
26
26
  "tslib": "2",
27
- "@formatjs/ecma402-abstract": "2.3.1",
28
- "@formatjs/intl-localematcher": "0.5.9"
27
+ "@formatjs/intl-localematcher": "0.6.0",
28
+ "@formatjs/ecma402-abstract": "2.3.3"
29
29
  },
30
30
  "devDependencies": {
31
- "@formatjs/intl-getcanonicallocales": "2.5.4",
32
- "@formatjs/intl-locale": "4.2.8",
33
- "@formatjs/intl-pluralrules": "5.4.1"
31
+ "@formatjs/intl-locale": "4.2.10",
32
+ "@formatjs/intl-pluralrules": "5.4.3",
33
+ "@formatjs/intl-getcanonicallocales": "2.5.4"
34
34
  },
35
35
  "bugs": {
36
36
  "url": "https://github.com/formatjs/formatjs/issues"
package/polyfill.iife.js CHANGED
@@ -2359,27 +2359,196 @@
2359
2359
  var ZERO = new decimal_default(0);
2360
2360
  var NEGATIVE_ZERO = new decimal_default(-0);
2361
2361
 
2362
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/262.js
2363
- function ToString(o) {
2364
- if (typeof o === "symbol") {
2365
- throw TypeError("Cannot convert a Symbol value to a string");
2362
+ // node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
2363
+ var extendStatics = function(d, b) {
2364
+ extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2365
+ d2.__proto__ = b2;
2366
+ } || function(d2, b2) {
2367
+ for (var p in b2)
2368
+ if (Object.prototype.hasOwnProperty.call(b2, p))
2369
+ d2[p] = b2[p];
2370
+ };
2371
+ return extendStatics(d, b);
2372
+ };
2373
+ function __extends(d, b) {
2374
+ if (typeof b !== "function" && b !== null)
2375
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2376
+ extendStatics(d, b);
2377
+ function __() {
2378
+ this.constructor = d;
2366
2379
  }
2367
- return String(o);
2380
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2381
+ }
2382
+ function __spreadArray(to, from, pack) {
2383
+ if (pack || arguments.length === 2)
2384
+ for (var i = 0, l = from.length, ar; i < l; i++) {
2385
+ if (ar || !(i in from)) {
2386
+ if (!ar)
2387
+ ar = Array.prototype.slice.call(from, 0, i);
2388
+ ar[i] = from[i];
2389
+ }
2390
+ }
2391
+ return to.concat(ar || Array.prototype.slice.call(from));
2392
+ }
2393
+
2394
+ // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/lib/index.js
2395
+ function memoize(fn, options) {
2396
+ var cache = options && options.cache ? options.cache : cacheDefault;
2397
+ var serializer = options && options.serializer ? options.serializer : serializerDefault;
2398
+ var strategy = options && options.strategy ? options.strategy : strategyDefault;
2399
+ return strategy(fn, {
2400
+ cache,
2401
+ serializer
2402
+ });
2403
+ }
2404
+ function isPrimitive(value) {
2405
+ return value == null || typeof value === "number" || typeof value === "boolean";
2406
+ }
2407
+ function monadic(fn, cache, serializer, arg) {
2408
+ var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
2409
+ var computedValue = cache.get(cacheKey);
2410
+ if (typeof computedValue === "undefined") {
2411
+ computedValue = fn.call(this, arg);
2412
+ cache.set(cacheKey, computedValue);
2413
+ }
2414
+ return computedValue;
2415
+ }
2416
+ function variadic(fn, cache, serializer) {
2417
+ var args = Array.prototype.slice.call(arguments, 3);
2418
+ var cacheKey = serializer(args);
2419
+ var computedValue = cache.get(cacheKey);
2420
+ if (typeof computedValue === "undefined") {
2421
+ computedValue = fn.apply(this, args);
2422
+ cache.set(cacheKey, computedValue);
2423
+ }
2424
+ return computedValue;
2425
+ }
2426
+ function assemble(fn, context, strategy, cache, serialize) {
2427
+ return strategy.bind(context, fn, cache, serialize);
2428
+ }
2429
+ function strategyDefault(fn, options) {
2430
+ var strategy = fn.length === 1 ? monadic : variadic;
2431
+ return assemble(fn, this, strategy, options.cache.create(), options.serializer);
2432
+ }
2433
+ function strategyVariadic(fn, options) {
2434
+ return assemble(fn, this, variadic, options.cache.create(), options.serializer);
2435
+ }
2436
+ function strategyMonadic(fn, options) {
2437
+ return assemble(fn, this, monadic, options.cache.create(), options.serializer);
2438
+ }
2439
+ var serializerDefault = function() {
2440
+ return JSON.stringify(arguments);
2441
+ };
2442
+ var ObjectWithoutPrototypeCache = (
2443
+ /** @class */
2444
+ function() {
2445
+ function ObjectWithoutPrototypeCache2() {
2446
+ this.cache = /* @__PURE__ */ Object.create(null);
2447
+ }
2448
+ ObjectWithoutPrototypeCache2.prototype.get = function(key) {
2449
+ return this.cache[key];
2450
+ };
2451
+ ObjectWithoutPrototypeCache2.prototype.set = function(key, value) {
2452
+ this.cache[key] = value;
2453
+ };
2454
+ return ObjectWithoutPrototypeCache2;
2455
+ }()
2456
+ );
2457
+ var cacheDefault = {
2458
+ create: function create() {
2459
+ return new ObjectWithoutPrototypeCache();
2460
+ }
2461
+ };
2462
+ var strategies = {
2463
+ variadic: strategyVariadic,
2464
+ monadic: strategyMonadic
2465
+ };
2466
+
2467
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/utils.js
2468
+ function repeat(s, times) {
2469
+ if (typeof s.repeat === "function") {
2470
+ return s.repeat(times);
2471
+ }
2472
+ var arr = new Array(times);
2473
+ for (var i = 0; i < arr.length; i++) {
2474
+ arr[i] = s;
2475
+ }
2476
+ return arr.join("");
2477
+ }
2478
+ function defineProperty(target, name, _a) {
2479
+ var value = _a.value;
2480
+ Object.defineProperty(target, name, {
2481
+ configurable: true,
2482
+ enumerable: false,
2483
+ writable: true,
2484
+ value
2485
+ });
2368
2486
  }
2369
- function ToNumber(val) {
2370
- if (val === void 0) {
2371
- return new Decimal(NaN);
2487
+ function invariant(condition, message, Err) {
2488
+ if (Err === void 0) {
2489
+ Err = Error;
2490
+ }
2491
+ if (!condition) {
2492
+ throw new Err(message);
2372
2493
  }
2373
- if (val === null) {
2374
- return ZERO;
2494
+ }
2495
+ var createMemoizedNumberFormat = memoize(function() {
2496
+ var _a;
2497
+ var args = [];
2498
+ for (var _i = 0; _i < arguments.length; _i++) {
2499
+ args[_i] = arguments[_i];
2375
2500
  }
2376
- if (typeof val === "boolean") {
2377
- return new Decimal(val ? 1 : 0);
2501
+ return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2502
+ }, {
2503
+ strategy: strategies.variadic
2504
+ });
2505
+ var createMemoizedDateTimeFormat = memoize(function() {
2506
+ var _a;
2507
+ var args = [];
2508
+ for (var _i = 0; _i < arguments.length; _i++) {
2509
+ args[_i] = arguments[_i];
2378
2510
  }
2379
- if (typeof val === "symbol" || typeof val === "bigint") {
2380
- throw new TypeError("Cannot convert symbol/bigint to number");
2511
+ return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2512
+ }, {
2513
+ strategy: strategies.variadic
2514
+ });
2515
+ var createMemoizedPluralRules = memoize(function() {
2516
+ var _a;
2517
+ var args = [];
2518
+ for (var _i = 0; _i < arguments.length; _i++) {
2519
+ args[_i] = arguments[_i];
2381
2520
  }
2382
- return new Decimal(Number(val));
2521
+ return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();
2522
+ }, {
2523
+ strategy: strategies.variadic
2524
+ });
2525
+ var createMemoizedLocale = memoize(function() {
2526
+ var _a;
2527
+ var args = [];
2528
+ for (var _i = 0; _i < arguments.length; _i++) {
2529
+ args[_i] = arguments[_i];
2530
+ }
2531
+ return new ((_a = Intl.Locale).bind.apply(_a, __spreadArray([void 0], args, false)))();
2532
+ }, {
2533
+ strategy: strategies.variadic
2534
+ });
2535
+ var createMemoizedListFormat = memoize(function() {
2536
+ var _a;
2537
+ var args = [];
2538
+ for (var _i = 0; _i < arguments.length; _i++) {
2539
+ args[_i] = arguments[_i];
2540
+ }
2541
+ return new ((_a = Intl.ListFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2542
+ }, {
2543
+ strategy: strategies.variadic
2544
+ });
2545
+
2546
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/262.js
2547
+ function ToString(o) {
2548
+ if (typeof o === "symbol") {
2549
+ throw TypeError("Cannot convert a Symbol value to a string");
2550
+ }
2551
+ return String(o);
2383
2552
  }
2384
2553
  function ToObject(arg) {
2385
2554
  if (arg == null) {
@@ -2418,6 +2587,51 @@
2418
2587
  }
2419
2588
  return Object.prototype.isPrototypeOf.call(P2, O);
2420
2589
  }
2590
+ function OrdinaryToPrimitive(O, hint) {
2591
+ var methodNames;
2592
+ if (hint === "string") {
2593
+ methodNames = ["toString", "valueOf"];
2594
+ } else {
2595
+ methodNames = ["valueOf", "toString"];
2596
+ }
2597
+ for (var _i = 0, methodNames_1 = methodNames; _i < methodNames_1.length; _i++) {
2598
+ var name_1 = methodNames_1[_i];
2599
+ var method = O[name_1];
2600
+ if (IsCallable(method)) {
2601
+ var result = method.call(O);
2602
+ if (typeof result !== "object") {
2603
+ return result;
2604
+ }
2605
+ }
2606
+ }
2607
+ throw new TypeError("Cannot convert object to primitive value");
2608
+ }
2609
+ function ToPrimitive(input, preferredType) {
2610
+ if (typeof input === "object" && input != null) {
2611
+ var exoticToPrim = Symbol.toPrimitive in input ? input[Symbol.toPrimitive] : void 0;
2612
+ var hint = void 0;
2613
+ if (exoticToPrim !== void 0) {
2614
+ if (preferredType === void 0) {
2615
+ hint = "default";
2616
+ } else if (preferredType === "string") {
2617
+ hint = "string";
2618
+ } else {
2619
+ invariant(preferredType === "number", 'preferredType must be "string" or "number"');
2620
+ hint = "number";
2621
+ }
2622
+ var result = exoticToPrim.call(input, hint);
2623
+ if (typeof result !== "object") {
2624
+ return result;
2625
+ }
2626
+ throw new TypeError("Cannot convert exotic object to primitive.");
2627
+ }
2628
+ if (preferredType === void 0) {
2629
+ preferredType = "number";
2630
+ }
2631
+ return OrdinaryToPrimitive(input, preferredType);
2632
+ }
2633
+ return input;
2634
+ }
2421
2635
 
2422
2636
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/CoerceOptionsToObject.js
2423
2637
  function CoerceOptionsToObject(options) {
@@ -2588,190 +2802,6 @@
2588
2802
  return true;
2589
2803
  }
2590
2804
 
2591
- // node_modules/.aspect_rules_js/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
2592
- var extendStatics = function(d, b) {
2593
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
2594
- d2.__proto__ = b2;
2595
- } || function(d2, b2) {
2596
- for (var p in b2)
2597
- if (Object.prototype.hasOwnProperty.call(b2, p))
2598
- d2[p] = b2[p];
2599
- };
2600
- return extendStatics(d, b);
2601
- };
2602
- function __extends(d, b) {
2603
- if (typeof b !== "function" && b !== null)
2604
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
2605
- extendStatics(d, b);
2606
- function __() {
2607
- this.constructor = d;
2608
- }
2609
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2610
- }
2611
- function __spreadArray(to, from, pack) {
2612
- if (pack || arguments.length === 2)
2613
- for (var i = 0, l = from.length, ar; i < l; i++) {
2614
- if (ar || !(i in from)) {
2615
- if (!ar)
2616
- ar = Array.prototype.slice.call(from, 0, i);
2617
- ar[i] = from[i];
2618
- }
2619
- }
2620
- return to.concat(ar || Array.prototype.slice.call(from));
2621
- }
2622
-
2623
- // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/lib/index.js
2624
- function memoize(fn, options) {
2625
- var cache = options && options.cache ? options.cache : cacheDefault;
2626
- var serializer = options && options.serializer ? options.serializer : serializerDefault;
2627
- var strategy = options && options.strategy ? options.strategy : strategyDefault;
2628
- return strategy(fn, {
2629
- cache,
2630
- serializer
2631
- });
2632
- }
2633
- function isPrimitive(value) {
2634
- return value == null || typeof value === "number" || typeof value === "boolean";
2635
- }
2636
- function monadic(fn, cache, serializer, arg) {
2637
- var cacheKey = isPrimitive(arg) ? arg : serializer(arg);
2638
- var computedValue = cache.get(cacheKey);
2639
- if (typeof computedValue === "undefined") {
2640
- computedValue = fn.call(this, arg);
2641
- cache.set(cacheKey, computedValue);
2642
- }
2643
- return computedValue;
2644
- }
2645
- function variadic(fn, cache, serializer) {
2646
- var args = Array.prototype.slice.call(arguments, 3);
2647
- var cacheKey = serializer(args);
2648
- var computedValue = cache.get(cacheKey);
2649
- if (typeof computedValue === "undefined") {
2650
- computedValue = fn.apply(this, args);
2651
- cache.set(cacheKey, computedValue);
2652
- }
2653
- return computedValue;
2654
- }
2655
- function assemble(fn, context, strategy, cache, serialize) {
2656
- return strategy.bind(context, fn, cache, serialize);
2657
- }
2658
- function strategyDefault(fn, options) {
2659
- var strategy = fn.length === 1 ? monadic : variadic;
2660
- return assemble(fn, this, strategy, options.cache.create(), options.serializer);
2661
- }
2662
- function strategyVariadic(fn, options) {
2663
- return assemble(fn, this, variadic, options.cache.create(), options.serializer);
2664
- }
2665
- function strategyMonadic(fn, options) {
2666
- return assemble(fn, this, monadic, options.cache.create(), options.serializer);
2667
- }
2668
- var serializerDefault = function() {
2669
- return JSON.stringify(arguments);
2670
- };
2671
- var ObjectWithoutPrototypeCache = (
2672
- /** @class */
2673
- function() {
2674
- function ObjectWithoutPrototypeCache2() {
2675
- this.cache = /* @__PURE__ */ Object.create(null);
2676
- }
2677
- ObjectWithoutPrototypeCache2.prototype.get = function(key) {
2678
- return this.cache[key];
2679
- };
2680
- ObjectWithoutPrototypeCache2.prototype.set = function(key, value) {
2681
- this.cache[key] = value;
2682
- };
2683
- return ObjectWithoutPrototypeCache2;
2684
- }()
2685
- );
2686
- var cacheDefault = {
2687
- create: function create() {
2688
- return new ObjectWithoutPrototypeCache();
2689
- }
2690
- };
2691
- var strategies = {
2692
- variadic: strategyVariadic,
2693
- monadic: strategyMonadic
2694
- };
2695
-
2696
- // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/utils.js
2697
- function repeat(s, times) {
2698
- if (typeof s.repeat === "function") {
2699
- return s.repeat(times);
2700
- }
2701
- var arr = new Array(times);
2702
- for (var i = 0; i < arr.length; i++) {
2703
- arr[i] = s;
2704
- }
2705
- return arr.join("");
2706
- }
2707
- function defineProperty(target, name, _a) {
2708
- var value = _a.value;
2709
- Object.defineProperty(target, name, {
2710
- configurable: true,
2711
- enumerable: false,
2712
- writable: true,
2713
- value
2714
- });
2715
- }
2716
- function invariant(condition, message, Err) {
2717
- if (Err === void 0) {
2718
- Err = Error;
2719
- }
2720
- if (!condition) {
2721
- throw new Err(message);
2722
- }
2723
- }
2724
- var createMemoizedNumberFormat = memoize(function() {
2725
- var _a;
2726
- var args = [];
2727
- for (var _i = 0; _i < arguments.length; _i++) {
2728
- args[_i] = arguments[_i];
2729
- }
2730
- return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2731
- }, {
2732
- strategy: strategies.variadic
2733
- });
2734
- var createMemoizedDateTimeFormat = memoize(function() {
2735
- var _a;
2736
- var args = [];
2737
- for (var _i = 0; _i < arguments.length; _i++) {
2738
- args[_i] = arguments[_i];
2739
- }
2740
- return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2741
- }, {
2742
- strategy: strategies.variadic
2743
- });
2744
- var createMemoizedPluralRules = memoize(function() {
2745
- var _a;
2746
- var args = [];
2747
- for (var _i = 0; _i < arguments.length; _i++) {
2748
- args[_i] = arguments[_i];
2749
- }
2750
- return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))();
2751
- }, {
2752
- strategy: strategies.variadic
2753
- });
2754
- var createMemoizedLocale = memoize(function() {
2755
- var _a;
2756
- var args = [];
2757
- for (var _i = 0; _i < arguments.length; _i++) {
2758
- args[_i] = arguments[_i];
2759
- }
2760
- return new ((_a = Intl.Locale).bind.apply(_a, __spreadArray([void 0], args, false)))();
2761
- }, {
2762
- strategy: strategies.variadic
2763
- });
2764
- var createMemoizedListFormat = memoize(function() {
2765
- var _a;
2766
- var args = [];
2767
- for (var _i = 0; _i < arguments.length; _i++) {
2768
- args[_i] = arguments[_i];
2769
- }
2770
- return new ((_a = Intl.ListFormat).bind.apply(_a, __spreadArray([void 0], args, false)))();
2771
- }, {
2772
- strategy: strategies.variadic
2773
- });
2774
-
2775
2805
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ApplyUnsignedRoundingMode.js
2776
2806
  function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
2777
2807
  if (x.eq(r1))
@@ -2862,9 +2892,7 @@
2862
2892
  decimal_default.set({
2863
2893
  toExpPos: 100
2864
2894
  });
2865
- function ComputeExponentForMagnitude(numberFormat, magnitude, _a) {
2866
- var getInternalSlots2 = _a.getInternalSlots;
2867
- var internalSlots = getInternalSlots2(numberFormat);
2895
+ function ComputeExponentForMagnitude(internalSlots, magnitude) {
2868
2896
  var notation = internalSlots.notation, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
2869
2897
  switch (notation) {
2870
2898
  case "standard":
@@ -2888,7 +2916,7 @@
2888
2916
  if (!thresholdMap) {
2889
2917
  return 0;
2890
2918
  }
2891
- var num = TEN.pow(magnitude).toString();
2919
+ var num = decimal_default.pow(10, magnitude).toString();
2892
2920
  var thresholds = Object.keys(thresholdMap);
2893
2921
  if (num < thresholds[0]) {
2894
2922
  return 0;
@@ -2945,10 +2973,10 @@
2945
2973
  toExpPos: 100
2946
2974
  });
2947
2975
  function ToRawFixedFn(n, f) {
2948
- return n.times(TEN.pow(-f));
2976
+ return n.times(decimal_default.pow(10, -f));
2949
2977
  }
2950
2978
  function findN1R1(x, f, roundingIncrement) {
2951
- var nx = x.times(TEN.pow(f)).floor();
2979
+ var nx = x.times(decimal_default.pow(10, f)).floor();
2952
2980
  var n1 = nx.div(roundingIncrement).floor().times(roundingIncrement);
2953
2981
  var r1 = ToRawFixedFn(n1, f);
2954
2982
  return {
@@ -2957,7 +2985,7 @@
2957
2985
  };
2958
2986
  }
2959
2987
  function findN2R2(x, f, roundingIncrement) {
2960
- var nx = x.times(TEN.pow(f)).ceil();
2988
+ var nx = x.times(decimal_default.pow(10, f)).ceil();
2961
2989
  var n2 = nx.div(roundingIncrement).ceil().times(roundingIncrement);
2962
2990
  var r2 = ToRawFixedFn(n2, f);
2963
2991
  return {
@@ -3016,21 +3044,15 @@
3016
3044
  }
3017
3045
 
3018
3046
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ToRawPrecision.js
3019
- decimal_default.set({
3020
- toExpPos: 100
3021
- });
3022
- function ToRawPrecisionFn(n, e, p) {
3023
- invariant(TEN.pow(p - 1).lessThanOrEqualTo(n) && n.lessThan(TEN.pow(p)), "n should be in the range ".concat(TEN.pow(p - 1), " <= n < ").concat(TEN.pow(p), " but got ").concat(n));
3024
- return n.times(TEN.pow(e.minus(p).plus(1)));
3025
- }
3026
3047
  function findN1E1R1(x, p) {
3027
- var maxN1 = TEN.pow(p);
3028
- var minN1 = TEN.pow(p - 1);
3048
+ var maxN1 = decimal_default.pow(10, p);
3049
+ var minN1 = decimal_default.pow(10, p - 1);
3029
3050
  var maxE1 = x.div(minN1).log(10).plus(p).minus(1).ceil();
3030
- for (var currentE1 = maxE1; ; currentE1 = currentE1.minus(1)) {
3031
- var currentN1 = x.div(TEN.pow(currentE1.minus(p).plus(1))).floor();
3051
+ var currentE1 = maxE1;
3052
+ while (true) {
3053
+ var currentN1 = x.div(decimal_default.pow(10, currentE1.minus(p).plus(1))).floor();
3032
3054
  if (currentN1.lessThan(maxN1) && currentN1.greaterThanOrEqualTo(minN1)) {
3033
- var currentR1 = ToRawPrecisionFn(currentN1, currentE1, p);
3055
+ var currentR1 = currentN1.times(decimal_default.pow(10, currentE1.minus(p).plus(1)));
3034
3056
  if (currentR1.lessThanOrEqualTo(x)) {
3035
3057
  return {
3036
3058
  n1: currentN1,
@@ -3039,16 +3061,18 @@
3039
3061
  };
3040
3062
  }
3041
3063
  }
3064
+ currentE1 = currentE1.minus(1);
3042
3065
  }
3043
3066
  }
3044
3067
  function findN2E2R2(x, p) {
3045
- var maxN2 = TEN.pow(p);
3046
- var minN2 = TEN.pow(p - 1);
3068
+ var maxN2 = decimal_default.pow(10, p);
3069
+ var minN2 = decimal_default.pow(10, p - 1);
3047
3070
  var minE2 = x.div(maxN2).log(10).plus(p).minus(1).floor();
3048
- for (var currentE2 = minE2; ; currentE2 = currentE2.plus(1)) {
3049
- var currentN2 = x.div(TEN.pow(currentE2.minus(p).plus(1))).ceil();
3071
+ var currentE2 = minE2;
3072
+ while (true) {
3073
+ var currentN2 = x.div(decimal_default.pow(10, currentE2.minus(p).plus(1))).ceil();
3050
3074
  if (currentN2.lessThan(maxN2) && currentN2.greaterThanOrEqualTo(minN2)) {
3051
- var currentR2 = ToRawPrecisionFn(currentN2, currentE2, p);
3075
+ var currentR2 = currentN2.times(decimal_default.pow(10, currentE2.minus(p).plus(1)));
3052
3076
  if (currentR2.greaterThanOrEqualTo(x)) {
3053
3077
  return {
3054
3078
  n2: currentN2,
@@ -3057,6 +3081,7 @@
3057
3081
  };
3058
3082
  }
3059
3083
  }
3084
+ currentE2 = currentE2.plus(1);
3060
3085
  }
3061
3086
  }
3062
3087
  function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
@@ -3115,7 +3140,8 @@
3115
3140
  }
3116
3141
 
3117
3142
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/FormatNumericToString.js
3118
- function FormatNumericToString(intlObject, x) {
3143
+ function FormatNumericToString(intlObject, _x) {
3144
+ var x = _x;
3119
3145
  var sign2;
3120
3146
  if (x.isZero() && x.isNegative()) {
3121
3147
  sign2 = "negative";
@@ -3185,8 +3211,7 @@
3185
3211
  }
3186
3212
 
3187
3213
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/ComputeExponent.js
3188
- function ComputeExponent(numberFormat, x, _a) {
3189
- var getInternalSlots2 = _a.getInternalSlots;
3214
+ function ComputeExponent(internalSlots, x) {
3190
3215
  if (x.isZero()) {
3191
3216
  return [0, 0];
3192
3217
  }
@@ -3194,11 +3219,9 @@
3194
3219
  x = x.negated();
3195
3220
  }
3196
3221
  var magnitude = x.log(10).floor();
3197
- var exponent = ComputeExponentForMagnitude(numberFormat, magnitude, {
3198
- getInternalSlots: getInternalSlots2
3199
- });
3200
- x = x.times(TEN.pow(-exponent));
3201
- var formatNumberResult = FormatNumericToString(getInternalSlots2(numberFormat), x);
3222
+ var exponent = ComputeExponentForMagnitude(internalSlots, magnitude);
3223
+ x = x.times(decimal_default.pow(10, -exponent));
3224
+ var formatNumberResult = FormatNumericToString(internalSlots, x);
3202
3225
  if (formatNumberResult.roundedNumber.isZero()) {
3203
3226
  return [exponent, magnitude.toNumber()];
3204
3227
  }
@@ -3207,9 +3230,7 @@
3207
3230
  return [exponent, magnitude.toNumber()];
3208
3231
  }
3209
3232
  return [
3210
- ComputeExponentForMagnitude(numberFormat, magnitude.plus(1), {
3211
- getInternalSlots: getInternalSlots2
3212
- }),
3233
+ ComputeExponentForMagnitude(internalSlots, magnitude.plus(1)),
3213
3234
  magnitude.plus(1).toNumber()
3214
3235
  ];
3215
3236
  }
@@ -4123,7 +4144,7 @@
4123
4144
  var unitName = void 0;
4124
4145
  var currencyNameData = data2.currencies[options.currency];
4125
4146
  if (currencyNameData) {
4126
- unitName = selectPlural(pl, numberResult.roundedNumber.times(TEN.pow(exponent)).toNumber(), currencyNameData.displayName);
4147
+ unitName = selectPlural(pl, numberResult.roundedNumber.times(decimal_default.pow(10, exponent)).toNumber(), currencyNameData.displayName);
4127
4148
  } else {
4128
4149
  unitName = options.currency;
4129
4150
  }
@@ -4155,11 +4176,11 @@
4155
4176
  var unitData = data2.units.simple[unit];
4156
4177
  var unitPattern = void 0;
4157
4178
  if (unitData) {
4158
- unitPattern = selectPlural(pl, numberResult.roundedNumber.times(TEN.pow(exponent)).toNumber(), data2.units.simple[unit][unitDisplay]);
4179
+ unitPattern = selectPlural(pl, numberResult.roundedNumber.times(decimal_default.pow(10, exponent)).toNumber(), data2.units.simple[unit][unitDisplay]);
4159
4180
  } else {
4160
4181
  var _c = unit.split("-per-"), numeratorUnit = _c[0], denominatorUnit = _c[1];
4161
4182
  unitData = data2.units.simple[numeratorUnit];
4162
- var numeratorUnitPattern = selectPlural(pl, numberResult.roundedNumber.times(TEN.pow(exponent)).toNumber(), data2.units.simple[numeratorUnit][unitDisplay]);
4183
+ var numeratorUnitPattern = selectPlural(pl, numberResult.roundedNumber.times(decimal_default.pow(10, exponent)).toNumber(), data2.units.simple[numeratorUnit][unitDisplay]);
4163
4184
  var perUnitPattern = data2.units.simple[denominatorUnit].perUnit[unitDisplay];
4164
4185
  if (perUnitPattern) {
4165
4186
  unitPattern = perUnitPattern.replace("{0}", numeratorUnitPattern);
@@ -4321,9 +4342,7 @@
4321
4342
  }
4322
4343
 
4323
4344
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/FormatApproximately.js
4324
- function FormatApproximately(numberFormat, result, _a) {
4325
- var getInternalSlots2 = _a.getInternalSlots;
4326
- var internalSlots = getInternalSlots2(numberFormat);
4345
+ function FormatApproximately(internalSlots, result) {
4327
4346
  var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
4328
4347
  var approximatelySign = symbols.approximatelySign;
4329
4348
  result.push({ type: "approximatelySign", value: approximatelySign });
@@ -4331,13 +4350,12 @@
4331
4350
  }
4332
4351
 
4333
4352
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/PartitionNumberPattern.js
4334
- function PartitionNumberPattern(numberFormat, x, _a) {
4335
- var _b;
4336
- var getInternalSlots2 = _a.getInternalSlots;
4337
- var internalSlots = getInternalSlots2(numberFormat);
4353
+ function PartitionNumberPattern(internalSlots, _x) {
4354
+ var _a;
4355
+ var x = _x;
4356
+ var magnitude = 0;
4338
4357
  var pl = internalSlots.pl, dataLocaleData = internalSlots.dataLocaleData, numberingSystem = internalSlots.numberingSystem;
4339
4358
  var symbols = dataLocaleData.numbers.symbols[numberingSystem] || dataLocaleData.numbers.symbols[dataLocaleData.numbers.nu[0]];
4340
- var magnitude = 0;
4341
4359
  var exponent = 0;
4342
4360
  var n;
4343
4361
  if (x.isNaN()) {
@@ -4351,10 +4369,9 @@
4351
4369
  x = x.times(100);
4352
4370
  }
4353
4371
  ;
4354
- _b = ComputeExponent(numberFormat, x, {
4355
- getInternalSlots: getInternalSlots2
4356
- }), exponent = _b[0], magnitude = _b[1];
4357
- x = x.times(TEN.pow(-exponent));
4372
+ _a = ComputeExponent(internalSlots, x), exponent = _a[0], // IMPL: We need to record the magnitude of the number
4373
+ magnitude = _a[1];
4374
+ x = x.times(decimal_default.pow(10, -exponent));
4358
4375
  }
4359
4376
  var formatNumberResult = FormatNumericToString(internalSlots, x);
4360
4377
  n = formatNumberResult.formattedString;
@@ -4398,32 +4415,49 @@
4398
4415
  }
4399
4416
  break;
4400
4417
  }
4401
- return formatToParts({ roundedNumber: x, formattedString: n, exponent, magnitude, sign: sign2 }, internalSlots.dataLocaleData, pl, internalSlots);
4418
+ return formatToParts({
4419
+ roundedNumber: x,
4420
+ formattedString: n,
4421
+ exponent,
4422
+ // IMPL: We're returning this for our implementation of formatToParts
4423
+ magnitude,
4424
+ sign: sign2
4425
+ }, internalSlots.dataLocaleData, pl, internalSlots);
4426
+ }
4427
+
4428
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/FormatNumeric.js
4429
+ function FormatNumeric(internalSlots, x) {
4430
+ var parts = PartitionNumberPattern(internalSlots, x);
4431
+ return parts.map(function(p) {
4432
+ return p.value;
4433
+ }).join("");
4402
4434
  }
4403
4435
 
4404
4436
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/PartitionNumberRangePattern.js
4405
4437
  function PartitionNumberRangePattern(numberFormat, x, y, _a) {
4406
4438
  var getInternalSlots2 = _a.getInternalSlots;
4407
- invariant(!x.isNaN() && !y.isNaN(), "Input must be a number");
4408
- var result = [];
4409
- var xResult = PartitionNumberPattern(numberFormat, x, { getInternalSlots: getInternalSlots2 });
4410
- var yResult = PartitionNumberPattern(numberFormat, y, { getInternalSlots: getInternalSlots2 });
4411
- if (xResult === yResult) {
4412
- return FormatApproximately(numberFormat, xResult, { getInternalSlots: getInternalSlots2 });
4413
- }
4414
- for (var _i = 0, xResult_1 = xResult; _i < xResult_1.length; _i++) {
4415
- var r = xResult_1[_i];
4416
- r.source = "startRange";
4417
- }
4418
- result = result.concat(xResult);
4439
+ invariant(!x.isNaN() && !y.isNaN(), "Input must be a number", RangeError);
4419
4440
  var internalSlots = getInternalSlots2(numberFormat);
4420
- var symbols = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem];
4421
- result.push({ type: "literal", value: symbols.rangeSign, source: "shared" });
4422
- for (var _b = 0, yResult_1 = yResult; _b < yResult_1.length; _b++) {
4423
- var r = yResult_1[_b];
4424
- r.source = "endRange";
4441
+ var xResult = PartitionNumberPattern(internalSlots, x);
4442
+ var yResult = PartitionNumberPattern(internalSlots, y);
4443
+ if (FormatNumeric(internalSlots, x) === FormatNumeric(internalSlots, y)) {
4444
+ var appxResult = FormatApproximately(internalSlots, xResult);
4445
+ appxResult.forEach(function(el) {
4446
+ el.source = "shared";
4447
+ });
4448
+ return appxResult;
4425
4449
  }
4426
- result = result.concat(yResult);
4450
+ var result = [];
4451
+ xResult.forEach(function(el) {
4452
+ el.source = "startRange";
4453
+ result.push(el);
4454
+ });
4455
+ var rangeSeparator = internalSlots.dataLocaleData.numbers.symbols[internalSlots.numberingSystem].rangeSign;
4456
+ result.push({ type: "literal", value: rangeSeparator, source: "shared" });
4457
+ yResult.forEach(function(el) {
4458
+ el.source = "endRange";
4459
+ result.push(el);
4460
+ });
4427
4461
  return CollapseNumberRange(numberFormat, result, { getInternalSlots: getInternalSlots2 });
4428
4462
  }
4429
4463
 
@@ -4456,7 +4490,7 @@
4456
4490
 
4457
4491
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/FormatNumericToParts.js
4458
4492
  function FormatNumericToParts(nf, x, implDetails) {
4459
- var parts = PartitionNumberPattern(nf, x, implDetails);
4493
+ var parts = PartitionNumberPattern(implDetails.getInternalSlots(nf), x);
4460
4494
  var result = ArrayCreate(0);
4461
4495
  for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
4462
4496
  var part = parts_1[_i];
@@ -8484,7 +8518,7 @@
8484
8518
  }).reduce(function(all, list) {
8485
8519
  return __spreadArray(__spreadArray([], all, true), list, true);
8486
8520
  }, []);
8487
- matches && (matches = !(expandedMatchedRegions.indexOf(locale.region || "") > 1 != shouldInclude));
8521
+ matches && (matches = !(expandedMatchedRegions.indexOf(locale.region || "") > -1 != shouldInclude));
8488
8522
  } else {
8489
8523
  matches && (matches = locale.region ? region === "*" || region === locale.region : true);
8490
8524
  }
@@ -8545,7 +8579,7 @@
8545
8579
  region: ""
8546
8580
  }, {
8547
8581
  language: supportedLocale.language,
8548
- script: desiredLSR.script,
8582
+ script: supportedLSR.script,
8549
8583
  region: ""
8550
8584
  }, data2);
8551
8585
  }
@@ -8910,7 +8944,8 @@
8910
8944
  mnfd = DefaultNumberOption(mnfd, 0, 100, void 0);
8911
8945
  mxfd = DefaultNumberOption(mxfd, 0, 100, void 0);
8912
8946
  if (mnfd === void 0) {
8913
- mnfd = Math.min(mnfdDefault, mxfd !== null && mxfd !== void 0 ? mxfd : 0);
8947
+ invariant(mxfd !== void 0, "maximumFractionDigits must be defined");
8948
+ mnfd = Math.min(mnfdDefault, mxfd);
8914
8949
  } else if (mxfd === void 0) {
8915
8950
  mxfd = Math.max(mxfdDefault, mnfd);
8916
8951
  } else if (mnfd > mxfd) {
@@ -8944,36 +8979,26 @@
8944
8979
  internalSlots.roundingPriority = "auto";
8945
8980
  }
8946
8981
  if (roundingIncrement !== 1) {
8947
- invariant(internalSlots.roundingType === "fractionDigits", "Invalid roundingType");
8948
- invariant(internalSlots.maximumFractionDigits === internalSlots.minimumFractionDigits, "With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.");
8982
+ invariant(internalSlots.roundingType === "fractionDigits", "Invalid roundingType", TypeError);
8983
+ invariant(internalSlots.maximumFractionDigits === internalSlots.minimumFractionDigits, "With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.", RangeError);
8949
8984
  }
8950
8985
  }
8951
8986
 
8952
8987
  // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/NumberFormat/SetNumberFormatUnitOptions.js
8953
- function SetNumberFormatUnitOptions(nf, options, _a) {
8988
+ function SetNumberFormatUnitOptions(internalSlots, options) {
8954
8989
  if (options === void 0) {
8955
8990
  options = /* @__PURE__ */ Object.create(null);
8956
8991
  }
8957
- var getInternalSlots2 = _a.getInternalSlots;
8958
- var internalSlots = getInternalSlots2(nf);
8959
8992
  var style = GetOption(options, "style", "string", ["decimal", "percent", "currency", "unit"], "decimal");
8960
8993
  internalSlots.style = style;
8961
8994
  var currency = GetOption(options, "currency", "string", void 0, void 0);
8962
- if (currency !== void 0 && !IsWellFormedCurrencyCode(currency)) {
8963
- throw RangeError("Malformed currency code");
8964
- }
8965
- if (style === "currency" && currency === void 0) {
8966
- throw TypeError("currency cannot be undefined");
8967
- }
8995
+ invariant(currency === void 0 || IsWellFormedCurrencyCode(currency), "Malformed currency code", RangeError);
8996
+ invariant(style !== "currency" || currency !== void 0, "currency cannot be undefined", TypeError);
8968
8997
  var currencyDisplay = GetOption(options, "currencyDisplay", "string", ["code", "symbol", "narrowSymbol", "name"], "symbol");
8969
8998
  var currencySign = GetOption(options, "currencySign", "string", ["standard", "accounting"], "standard");
8970
8999
  var unit = GetOption(options, "unit", "string", void 0, void 0);
8971
- if (unit !== void 0 && !IsWellFormedUnitIdentifier(unit)) {
8972
- throw RangeError("Invalid unit argument for Intl.NumberFormat()");
8973
- }
8974
- if (style === "unit" && unit === void 0) {
8975
- throw TypeError("unit cannot be undefined");
8976
- }
9000
+ invariant(unit === void 0 || IsWellFormedUnitIdentifier(unit), "Invalid unit argument for Intl.NumberFormat()", RangeError);
9001
+ invariant(style !== "unit" || unit !== void 0, "unit cannot be undefined", TypeError);
8977
9002
  var unitDisplay = GetOption(options, "unitDisplay", "string", ["short", "narrow", "long"], "short");
8978
9003
  if (style === "currency") {
8979
9004
  internalSlots.currency = currency.toUpperCase();
@@ -9015,7 +9040,7 @@
9015
9040
  internalSlots.dataLocale = r.dataLocale;
9016
9041
  internalSlots.numberingSystem = r.nu;
9017
9042
  internalSlots.dataLocaleData = dataLocaleData;
9018
- SetNumberFormatUnitOptions(nf, options, { getInternalSlots: getInternalSlots2 });
9043
+ SetNumberFormatUnitOptions(internalSlots, options);
9019
9044
  var style = internalSlots.style;
9020
9045
  var notation = GetOption(options, "notation", "string", ["standard", "scientific", "engineering", "compact"], "standard");
9021
9046
  internalSlots.notation = notation;
@@ -9079,6 +9104,31 @@
9079
9104
  RangePatternType2["endRange"] = "endRange";
9080
9105
  })(RangePatternType || (RangePatternType = {}));
9081
9106
 
9107
+ // node_modules/.aspect_rules_js/@formatjs+ecma402-abstract@0.0.0/node_modules/@formatjs/ecma402-abstract/lib/ToIntlMathematicalValue.js
9108
+ function ToIntlMathematicalValue(input) {
9109
+ var primValue = ToPrimitive(input, "number");
9110
+ if (typeof primValue === "bigint") {
9111
+ return new decimal_default(primValue);
9112
+ }
9113
+ if (primValue === void 0) {
9114
+ return new decimal_default(NaN);
9115
+ }
9116
+ if (primValue === true) {
9117
+ return new decimal_default(1);
9118
+ }
9119
+ if (primValue === false) {
9120
+ return new decimal_default(0);
9121
+ }
9122
+ if (primValue === null) {
9123
+ return new decimal_default(0);
9124
+ }
9125
+ try {
9126
+ return new decimal_default(primValue);
9127
+ } catch (e) {
9128
+ return new decimal_default(NaN);
9129
+ }
9130
+ }
9131
+
9082
9132
  // packages/intl-numberformat/src/currency-digits.generated.ts
9083
9133
  var currencyDigitsData = {
9084
9134
  "ADP": 0,
@@ -9219,19 +9269,29 @@
9219
9269
  return this;
9220
9270
  };
9221
9271
  function formatToParts2(x) {
9222
- return FormatNumericToParts(this, toNumeric(x), {
9272
+ return FormatNumericToParts(this, ToIntlMathematicalValue(x), {
9223
9273
  getInternalSlots
9224
9274
  });
9225
9275
  }
9226
9276
  function formatRange(start, end) {
9227
- return FormatNumericRange(this, toNumeric(start), toNumeric(end), {
9228
- getInternalSlots
9229
- });
9277
+ return FormatNumericRange(
9278
+ this,
9279
+ ToIntlMathematicalValue(start),
9280
+ ToIntlMathematicalValue(end),
9281
+ {
9282
+ getInternalSlots
9283
+ }
9284
+ );
9230
9285
  }
9231
9286
  function formatRangeToParts(start, end) {
9232
- return FormatNumericRangeToParts(this, toNumeric(start), toNumeric(end), {
9233
- getInternalSlots
9234
- });
9287
+ return FormatNumericRangeToParts(
9288
+ this,
9289
+ ToIntlMathematicalValue(start),
9290
+ ToIntlMathematicalValue(end),
9291
+ {
9292
+ getInternalSlots
9293
+ }
9294
+ );
9235
9295
  }
9236
9296
  try {
9237
9297
  Object.defineProperty(formatToParts2, "name", {
@@ -9286,13 +9346,9 @@
9286
9346
  );
9287
9347
  }
9288
9348
  const internalSlots = getInternalSlots(this);
9289
- const numberFormat = this;
9290
9349
  let boundFormat = internalSlots.boundFormat;
9291
9350
  if (boundFormat === void 0) {
9292
- boundFormat = (value) => {
9293
- const x = toNumeric(value);
9294
- return numberFormat.formatToParts(x).map((x2) => x2.value).join("");
9295
- };
9351
+ boundFormat = (value) => FormatNumeric(internalSlots, ToIntlMathematicalValue(value));
9296
9352
  try {
9297
9353
  Object.defineProperty(boundFormat, "name", {
9298
9354
  configurable: true,
@@ -9357,12 +9413,6 @@ Please __addLocaleData before adding additional unit data`);
9357
9413
  return NumberFormat.__defaultLocale;
9358
9414
  };
9359
9415
  NumberFormat.polyfilled = true;
9360
- function toNumeric(val) {
9361
- if (typeof val === "bigint") {
9362
- return new decimal_default(val.toString());
9363
- }
9364
- return ToNumber(val);
9365
- }
9366
9416
  try {
9367
9417
  if (typeof Symbol !== "undefined") {
9368
9418
  Object.defineProperty(NumberFormat.prototype, Symbol.toStringTag, {
package/src/core.js CHANGED
@@ -5,8 +5,6 @@ var tslib_1 = require("tslib");
5
5
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
6
6
  var currency_digits_generated_1 = require("./currency-digits.generated");
7
7
  var numbering_systems_generated_1 = require("./numbering-systems.generated");
8
- // eslint-disable-next-line import/no-cycle
9
- var decimal_js_1 = tslib_1.__importDefault(require("decimal.js"));
10
8
  var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
11
9
  var RESOLVED_OPTIONS_KEYS = [
12
10
  'locale',
@@ -57,17 +55,17 @@ exports.NumberFormat = function (locales, options) {
57
55
  return this;
58
56
  };
59
57
  function formatToParts(x) {
60
- return (0, ecma402_abstract_1.FormatNumericToParts)(this, toNumeric(x), {
58
+ return (0, ecma402_abstract_1.FormatNumericToParts)(this, (0, ecma402_abstract_1.ToIntlMathematicalValue)(x), {
61
59
  getInternalSlots: get_internal_slots_1.default,
62
60
  });
63
61
  }
64
62
  function formatRange(start, end) {
65
- return (0, ecma402_abstract_1.FormatNumericRange)(this, toNumeric(start), toNumeric(end), {
63
+ return (0, ecma402_abstract_1.FormatNumericRange)(this, (0, ecma402_abstract_1.ToIntlMathematicalValue)(start), (0, ecma402_abstract_1.ToIntlMathematicalValue)(end), {
66
64
  getInternalSlots: get_internal_slots_1.default,
67
65
  });
68
66
  }
69
67
  function formatRangeToParts(start, end) {
70
- return (0, ecma402_abstract_1.FormatNumericRangeToParts)(this, toNumeric(start), toNumeric(end), {
68
+ return (0, ecma402_abstract_1.FormatNumericRangeToParts)(this, (0, ecma402_abstract_1.ToIntlMathematicalValue)(start), (0, ecma402_abstract_1.ToIntlMathematicalValue)(end), {
71
69
  getInternalSlots: get_internal_slots_1.default,
72
70
  });
73
71
  }
@@ -126,18 +124,11 @@ var formatDescriptor = {
126
124
  throw TypeError('Intl.NumberFormat format property accessor called on incompatible receiver');
127
125
  }
128
126
  var internalSlots = (0, get_internal_slots_1.default)(this);
129
- // eslint-disable-next-line @typescript-eslint/no-this-alias
130
- var numberFormat = this;
131
127
  var boundFormat = internalSlots.boundFormat;
132
128
  if (boundFormat === undefined) {
133
129
  // https://tc39.es/proposal-unified-intl-numberformat/section11/numberformat_diff_out.html#sec-number-format-functions
134
130
  boundFormat = function (value) {
135
- // TODO: check bigint
136
- var x = toNumeric(value);
137
- return numberFormat
138
- .formatToParts(x)
139
- .map(function (x) { return x.value; })
140
- .join('');
131
+ return (0, ecma402_abstract_1.FormatNumeric)(internalSlots, (0, ecma402_abstract_1.ToIntlMathematicalValue)(value));
141
132
  };
142
133
  try {
143
134
  // https://github.com/tc39/test262/blob/master/test/intl402/NumberFormat/prototype/format/format-function-name.js
@@ -215,12 +206,6 @@ exports.NumberFormat.getDefaultLocale = function () {
215
206
  return exports.NumberFormat.__defaultLocale;
216
207
  };
217
208
  exports.NumberFormat.polyfilled = true;
218
- function toNumeric(val) {
219
- if (typeof val === 'bigint') {
220
- return new decimal_js_1.default(val.toString());
221
- }
222
- return (0, ecma402_abstract_1.ToNumber)(val);
223
- }
224
209
  try {
225
210
  // IE11 does not have Symbol
226
211
  if (typeof Symbol !== 'undefined') {
package/src/types.d.ts CHANGED
@@ -2,10 +2,10 @@ import { NumberFormatLocaleInternalData, NumberFormatOptions, NumberFormatPart,
2
2
  import Decimal from 'decimal.js';
3
3
  export interface NumberFormat {
4
4
  resolvedOptions(): ResolvedNumberFormatOptions;
5
- formatToParts(x: number | bigint | Decimal): NumberFormatPart[];
6
- format(x: number | bigint | Decimal): string;
7
- formatRange(start: number | bigint | Decimal, end: number | bigint | Decimal): string;
8
- formatRangeToParts(start: number | bigint | Decimal, end: number | bigint | Decimal): NumberRangeToParts[];
5
+ formatToParts(x: number | bigint | Decimal | string): NumberFormatPart[];
6
+ format(x: number | bigint | Decimal | string): string;
7
+ formatRange(start: number | bigint | Decimal | string, end: number | bigint | Decimal | string): string;
8
+ formatRangeToParts(start: number | bigint | Decimal | string, end: number | bigint | Decimal | string): NumberRangeToParts[];
9
9
  }
10
10
  export interface NumberFormatConstructor {
11
11
  new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;