@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/lib/src/core.js CHANGED
@@ -2,6 +2,7 @@ import { CanonicalizeLocaleList, FormatNumericRange, FormatNumericRangeToParts,
2
2
  import { currencyDigitsData } from './currency-digits.generated';
3
3
  import { numberingSystemNames } from './numbering-systems.generated';
4
4
  // eslint-disable-next-line import/no-cycle
5
+ import Decimal from 'decimal.js';
5
6
  import getInternalSlots from './get_internal_slots';
6
7
  var RESOLVED_OPTIONS_KEYS = [
7
8
  'locale',
@@ -57,10 +58,14 @@ function formatToParts(x) {
57
58
  });
58
59
  }
59
60
  function formatRange(start, end) {
60
- return FormatNumericRange(this, start, end, { getInternalSlots: getInternalSlots });
61
+ return FormatNumericRange(this, toNumeric(start), toNumeric(end), {
62
+ getInternalSlots: getInternalSlots,
63
+ });
61
64
  }
62
65
  function formatRangeToParts(start, end) {
63
- return FormatNumericRangeToParts(this, start, end, { getInternalSlots: getInternalSlots });
66
+ return FormatNumericRangeToParts(this, toNumeric(start), toNumeric(end), {
67
+ getInternalSlots: getInternalSlots,
68
+ });
64
69
  }
65
70
  try {
66
71
  Object.defineProperty(formatToParts, 'name', {
@@ -208,7 +213,7 @@ NumberFormat.getDefaultLocale = function () {
208
213
  NumberFormat.polyfilled = true;
209
214
  function toNumeric(val) {
210
215
  if (typeof val === 'bigint') {
211
- return val;
216
+ return new Decimal(val.toString());
212
217
  }
213
218
  return ToNumber(val);
214
219
  }
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-numberformat",
3
- "version": "8.14.6",
3
+ "version": "8.15.0",
4
4
  "description": "Ponyfill for ES2020 Intl.NumberFormat",
5
5
  "keywords": [
6
6
  "polyfill",
@@ -22,14 +22,15 @@
22
22
  "url": "git+https://github.com/formatjs/formatjs.git"
23
23
  },
24
24
  "dependencies": {
25
+ "decimal.js": "10",
25
26
  "tslib": "2",
26
- "@formatjs/ecma402-abstract": "2.2.5",
27
- "@formatjs/intl-localematcher": "0.5.8"
27
+ "@formatjs/ecma402-abstract": "2.3.0",
28
+ "@formatjs/intl-localematcher": "0.5.9"
28
29
  },
29
30
  "devDependencies": {
30
- "@formatjs/intl-getcanonicallocales": "2.5.3",
31
- "@formatjs/intl-locale": "4.2.6",
32
- "@formatjs/intl-pluralrules": "5.3.6"
31
+ "@formatjs/intl-pluralrules": "5.4.0",
32
+ "@formatjs/intl-locale": "4.2.7",
33
+ "@formatjs/intl-getcanonicallocales": "2.5.4"
33
34
  },
34
35
  "bugs": {
35
36
  "url": "https://github.com/formatjs/formatjs/issues"