@formatjs/intl-supportedvaluesof 3.0.1 → 3.1.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-supportedvaluesof",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "Intl.supportedValuesOf polyfill",
5
5
  "keywords": [
6
6
  "ecma402",
@@ -34,6 +34,6 @@
34
34
  "./should-polyfill.js": "./should-polyfill.js"
35
35
  },
36
36
  "dependencies": {
37
- "@formatjs/fast-memoize": "3.1.7"
37
+ "@formatjs/fast-memoize": "3.1.8"
38
38
  }
39
39
  }
package/polyfill-force.js CHANGED
@@ -1,11 +1,13 @@
1
1
  import { memoize, strategies } from "@formatjs/fast-memoize";
2
2
  // packages/ecma262-abstract/ToString.js
3
+ const StringConstructor = String;
4
+ const TypeErrorConstructor = TypeError;
3
5
  /**
4
6
  * https://tc39.es/ecma262/#sec-tostring
5
7
  */
6
8
  function ToString(o) {
7
- if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
8
- return String(o);
9
+ if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
10
+ return StringConstructor(o);
9
11
  }
10
12
  // packages/intl-supportedvaluesof/memoize.ts
11
13
  /**
@@ -393,6 +395,13 @@ function isSupportedCollation(collation) {
393
395
  function getSupportedCollations() {
394
396
  return collations.filter(isSupportedCollation).sort();
395
397
  }
398
+ Number.isInteger;
399
+ Number.isFinite;
400
+ Number.isSafeInteger;
401
+ Array.prototype.every;
402
+ Array.prototype.some;
403
+ Array.prototype.includes;
404
+ Array.prototype.indexOf;
396
405
  // packages/ecma402-abstract/utils.js
397
406
  function defineProperty(target, name, { value }) {
398
407
  Object.defineProperty(target, name, {
@@ -409,11 +418,56 @@ function ensureIntl() {
409
418
  writable: true,
410
419
  value: {}
411
420
  });
421
+ if (providerIntl === void 0) providerIntl = Intl;
412
422
  return Intl;
413
423
  }
414
424
  const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
415
425
  memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
416
426
  memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
427
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
428
+ strategies.variadic;
429
+ let providerIntl = globalThis.Intl;
430
+ function ownIntlProvider(name) {
431
+ const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
432
+ return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
433
+ }
434
+ let numberFormatProvider = ownIntlProvider("NumberFormat");
435
+ let listFormatProvider = ownIntlProvider("ListFormat");
436
+ const getFormatterPrototype = Object.getPrototypeOf;
437
+ const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
438
+ const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
439
+ const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
440
+ const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
441
+ const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
442
+ const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
443
+ function findFormatterPartsMethod(Constructor) {
444
+ const cached = getPartsMethod(Constructor);
445
+ if (cached) return cached;
446
+ let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
447
+ while (prototype != null) {
448
+ const inherited = getPartsOwner(prototype);
449
+ if (inherited) {
450
+ setPartsMethod(Constructor, inherited);
451
+ return inherited;
452
+ }
453
+ const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
454
+ const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
455
+ if (value && typeof value.value === "function") {
456
+ setPartsMethod(Constructor, value.value);
457
+ setPartsOwner(prototype, value.value);
458
+ return value.value;
459
+ }
460
+ prototype = getFormatterPrototype(prototype);
461
+ }
462
+ }
463
+ if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
464
+ if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
465
+ const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
466
+ numberFormatMemoizers.get.bind(numberFormatMemoizers);
467
+ numberFormatMemoizers.set.bind(numberFormatMemoizers);
468
+ const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
469
+ listFormatMemoizers.get.bind(listFormatMemoizers);
470
+ listFormatMemoizers.set.bind(listFormatMemoizers);
417
471
  // node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-values@0.0.0/node_modules/@formatjs_generated/cldr.supported-values/currencies.js
418
472
  const currencies = [
419
473
  "ADP",
@@ -1041,7 +1095,6 @@ const timezones = [
1041
1095
  "America/Montserrat",
1042
1096
  "America/Nassau",
1043
1097
  "America/New_York",
1044
- "America/Nipigon",
1045
1098
  "America/Nome",
1046
1099
  "America/Noronha",
1047
1100
  "America/North_Dakota/Beulah",
@@ -1050,7 +1103,6 @@ const timezones = [
1050
1103
  "America/Nuuk",
1051
1104
  "America/Ojinaga",
1052
1105
  "America/Panama",
1053
- "America/Pangnirtung",
1054
1106
  "America/Paramaribo",
1055
1107
  "America/Phoenix",
1056
1108
  "America/Port-au-Prince",
@@ -1058,7 +1110,6 @@ const timezones = [
1058
1110
  "America/Porto_Velho",
1059
1111
  "America/Puerto_Rico",
1060
1112
  "America/Punta_Arenas",
1061
- "America/Rainy_River",
1062
1113
  "America/Rankin_Inlet",
1063
1114
  "America/Recife",
1064
1115
  "America/Regina",
@@ -1079,7 +1130,6 @@ const timezones = [
1079
1130
  "America/Swift_Current",
1080
1131
  "America/Tegucigalpa",
1081
1132
  "America/Thule",
1082
- "America/Thunder_Bay",
1083
1133
  "America/Tijuana",
1084
1134
  "America/Toronto",
1085
1135
  "America/Tortola",
@@ -1087,7 +1137,6 @@ const timezones = [
1087
1137
  "America/Whitehorse",
1088
1138
  "America/Winnipeg",
1089
1139
  "America/Yakutat",
1090
- "America/Yellowknife",
1091
1140
  "Antarctica/Casey",
1092
1141
  "Antarctica/Davis",
1093
1142
  "Antarctica/DumontDUrville",
@@ -1117,7 +1166,6 @@ const timezones = [
1117
1166
  "Asia/Bishkek",
1118
1167
  "Asia/Brunei",
1119
1168
  "Asia/Chita",
1120
- "Asia/Choibalsan",
1121
1169
  "Asia/Colombo",
1122
1170
  "Asia/Damascus",
1123
1171
  "Asia/Dhaka",
@@ -1196,7 +1244,6 @@ const timezones = [
1196
1244
  "Australia/Adelaide",
1197
1245
  "Australia/Brisbane",
1198
1246
  "Australia/Broken_Hill",
1199
- "Australia/Currie",
1200
1247
  "Australia/Darwin",
1201
1248
  "Australia/Eucla",
1202
1249
  "Australia/Hobart",
@@ -1283,7 +1330,6 @@ const timezones = [
1283
1330
  "Europe/Tallinn",
1284
1331
  "Europe/Tirane",
1285
1332
  "Europe/Ulyanovsk",
1286
- "Europe/Uzhgorod",
1287
1333
  "Europe/Vaduz",
1288
1334
  "Europe/Vatican",
1289
1335
  "Europe/Vienna",
@@ -1291,7 +1337,6 @@ const timezones = [
1291
1337
  "Europe/Volgograd",
1292
1338
  "Europe/Warsaw",
1293
1339
  "Europe/Zagreb",
1294
- "Europe/Zaporozhye",
1295
1340
  "Europe/Zurich",
1296
1341
  "Indian/Antananarivo",
1297
1342
  "Indian/Chagos",
@@ -1355,7 +1400,8 @@ const timezones = [
1355
1400
  */
1356
1401
  function isSupportedTimeZone(timeZone) {
1357
1402
  try {
1358
- return createMemoizedDateTimeFormat("en", { timeZone }).resolvedOptions().timeZone === timeZone;
1403
+ createMemoizedDateTimeFormat("en", { timeZone });
1404
+ return true;
1359
1405
  } catch {}
1360
1406
  return false;
1361
1407
  }