@formatjs/intl-numberformat 8.14.6 → 8.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/core.js CHANGED
@@ -6,6 +6,7 @@ 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
8
  // eslint-disable-next-line import/no-cycle
9
+ var decimal_js_1 = tslib_1.__importDefault(require("decimal.js"));
9
10
  var get_internal_slots_1 = tslib_1.__importDefault(require("./get_internal_slots"));
10
11
  var RESOLVED_OPTIONS_KEYS = [
11
12
  'locale',
@@ -61,10 +62,14 @@ function formatToParts(x) {
61
62
  });
62
63
  }
63
64
  function formatRange(start, end) {
64
- return (0, ecma402_abstract_1.FormatNumericRange)(this, start, end, { getInternalSlots: get_internal_slots_1.default });
65
+ return (0, ecma402_abstract_1.FormatNumericRange)(this, toNumeric(start), toNumeric(end), {
66
+ getInternalSlots: get_internal_slots_1.default,
67
+ });
65
68
  }
66
69
  function formatRangeToParts(start, end) {
67
- return (0, ecma402_abstract_1.FormatNumericRangeToParts)(this, start, end, { getInternalSlots: get_internal_slots_1.default });
70
+ return (0, ecma402_abstract_1.FormatNumericRangeToParts)(this, toNumeric(start), toNumeric(end), {
71
+ getInternalSlots: get_internal_slots_1.default,
72
+ });
68
73
  }
69
74
  try {
70
75
  Object.defineProperty(formatToParts, 'name', {
@@ -212,7 +217,7 @@ exports.NumberFormat.getDefaultLocale = function () {
212
217
  exports.NumberFormat.polyfilled = true;
213
218
  function toNumeric(val) {
214
219
  if (typeof val === 'bigint') {
215
- return val;
220
+ return new decimal_js_1.default(val.toString());
216
221
  }
217
222
  return (0, ecma402_abstract_1.ToNumber)(val);
218
223
  }
package/src/types.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { NumberFormatLocaleInternalData, RawNumberLocaleData, ResolvedNumberFormatOptions, NumberFormatOptions, NumberFormatPart, NumberRangeToParts } from '@formatjs/ecma402-abstract';
1
+ import { NumberFormatLocaleInternalData, NumberFormatOptions, NumberFormatPart, NumberRangeToParts, RawNumberLocaleData, ResolvedNumberFormatOptions } from '@formatjs/ecma402-abstract';
2
+ import Decimal from 'decimal.js';
2
3
  export interface NumberFormat {
3
4
  resolvedOptions(): ResolvedNumberFormatOptions;
4
- formatToParts(x: number): NumberFormatPart[];
5
- format(x: number): string;
6
- formatRange(start: number, end: number): string;
7
- formatRangeToParts(start: number, end: number): NumberRangeToParts[];
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[];
8
9
  }
9
10
  export interface NumberFormatConstructor {
10
11
  new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat;