@formatjs/intl-numberformat 8.9.1 → 8.10.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.
@@ -34,6 +34,30 @@ function supportsES2020() {
34
34
  }
35
35
  return true;
36
36
  }
37
+ /**
38
+ * Check if Intl.NumberFormat is ES2020 compatible.
39
+ * Caveat: we are not checking `toLocaleString`.
40
+ *
41
+ * @public
42
+ * @param unit unit to check
43
+ */
44
+ function supportsES2023() {
45
+ try {
46
+ var s = new Intl.NumberFormat('en', {
47
+ notation: 'compact',
48
+ minimumSignificantDigits: 3,
49
+ maximumSignificantDigits: 3,
50
+ minimumFractionDigits: 2,
51
+ maximumFractionDigits: 2,
52
+ // @ts-ignore TS types are old
53
+ roundingPriority: 'morePrecision',
54
+ }).format(1e8);
55
+ return s === '100.00M';
56
+ }
57
+ catch (e) {
58
+ return false;
59
+ }
60
+ }
37
61
  function supportedLocalesOf(locale) {
38
62
  if (!locale) {
39
63
  return true;
@@ -46,6 +70,7 @@ export function shouldPolyfill(locale) {
46
70
  if (typeof Intl === 'undefined' ||
47
71
  !('NumberFormat' in Intl) ||
48
72
  !supportsES2020() ||
73
+ !supportsES2023() ||
49
74
  onlySupportsEn() ||
50
75
  !supportedLocalesOf(locale)) {
51
76
  return locale ? match([locale], supportedLocales, 'en') : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-numberformat",
3
- "version": "8.9.1",
3
+ "version": "8.10.0",
4
4
  "description": "Ponyfill for ES2020 Intl.NumberFormat",
5
5
  "keywords": [
6
6
  "polyfill",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "tslib": "^2.4.0",
26
- "@formatjs/ecma402-abstract": "1.18.1",
27
- "@formatjs/intl-localematcher": "0.5.3"
26
+ "@formatjs/intl-localematcher": "0.5.4",
27
+ "@formatjs/ecma402-abstract": "1.18.2"
28
28
  },
29
29
  "devDependencies": {
30
- "@formatjs/intl-pluralrules": "5.2.11",
30
+ "@formatjs/intl-locale": "3.4.5",
31
31
  "@formatjs/intl-getcanonicallocales": "2.3.0",
32
- "@formatjs/intl-locale": "3.4.4"
32
+ "@formatjs/intl-pluralrules": "5.2.12"
33
33
  },
34
34
  "bugs": {
35
35
  "url": "https://github.com/formatjs/formatjs/issues"
package/polyfill.iife.js CHANGED
@@ -5860,8 +5860,8 @@
5860
5860
  if (!result.distances[desired]) {
5861
5861
  result.distances[desired] = {};
5862
5862
  }
5863
- supportedLocales2.forEach(function(supported, j) {
5864
- var distance = findMatchingDistance(desired, supported) + j + i * 40;
5863
+ supportedLocales2.forEach(function(supported) {
5864
+ var distance = findMatchingDistance(desired, supported) + 0 + i * 40;
5865
5865
  result.distances[desired][supported] = distance;
5866
5866
  if (distance < lowestDistance) {
5867
5867
  lowestDistance = distance;
@@ -6634,6 +6634,22 @@
6634
6634
  }
6635
6635
  return true;
6636
6636
  }
6637
+ function supportsES2023() {
6638
+ try {
6639
+ var s = new Intl.NumberFormat("en", {
6640
+ notation: "compact",
6641
+ minimumSignificantDigits: 3,
6642
+ maximumSignificantDigits: 3,
6643
+ minimumFractionDigits: 2,
6644
+ maximumFractionDigits: 2,
6645
+ // @ts-ignore TS types are old
6646
+ roundingPriority: "morePrecision"
6647
+ }).format(1e8);
6648
+ return s === "100.00M";
6649
+ } catch (e) {
6650
+ return false;
6651
+ }
6652
+ }
6637
6653
  function supportedLocalesOf2(locale) {
6638
6654
  if (!locale) {
6639
6655
  return true;
@@ -6645,7 +6661,7 @@
6645
6661
  if (locale === void 0) {
6646
6662
  locale = "en";
6647
6663
  }
6648
- if (typeof Intl === "undefined" || !("NumberFormat" in Intl) || !supportsES2020() || onlySupportsEn() || !supportedLocalesOf2(locale)) {
6664
+ if (typeof Intl === "undefined" || !("NumberFormat" in Intl) || !supportsES2020() || !supportsES2023() || onlySupportsEn() || !supportedLocalesOf2(locale)) {
6649
6665
  return locale ? match([locale], supportedLocales, "en") : void 0;
6650
6666
  }
6651
6667
  }
@@ -37,6 +37,30 @@ function supportsES2020() {
37
37
  }
38
38
  return true;
39
39
  }
40
+ /**
41
+ * Check if Intl.NumberFormat is ES2020 compatible.
42
+ * Caveat: we are not checking `toLocaleString`.
43
+ *
44
+ * @public
45
+ * @param unit unit to check
46
+ */
47
+ function supportsES2023() {
48
+ try {
49
+ var s = new Intl.NumberFormat('en', {
50
+ notation: 'compact',
51
+ minimumSignificantDigits: 3,
52
+ maximumSignificantDigits: 3,
53
+ minimumFractionDigits: 2,
54
+ maximumFractionDigits: 2,
55
+ // @ts-ignore TS types are old
56
+ roundingPriority: 'morePrecision',
57
+ }).format(1e8);
58
+ return s === '100.00M';
59
+ }
60
+ catch (e) {
61
+ return false;
62
+ }
63
+ }
40
64
  function supportedLocalesOf(locale) {
41
65
  if (!locale) {
42
66
  return true;
@@ -49,6 +73,7 @@ function shouldPolyfill(locale) {
49
73
  if (typeof Intl === 'undefined' ||
50
74
  !('NumberFormat' in Intl) ||
51
75
  !supportsES2020() ||
76
+ !supportsES2023() ||
52
77
  onlySupportsEn() ||
53
78
  !supportedLocalesOf(locale)) {
54
79
  return locale ? (0, intl_localematcher_1.match)([locale], supported_locales_generated_1.supportedLocales, 'en') : undefined;