@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/polyfill.iife.js CHANGED
@@ -3,14 +3,23 @@ function shouldPolyfill() {
3
3
  return typeof Intl === "undefined" || !("supportedValuesOf" in Intl);
4
4
  }
5
5
  // packages/ecma262-abstract/ToString.js
6
+ const StringConstructor = String;
7
+ const TypeErrorConstructor = TypeError;
6
8
  /**
7
9
  * https://tc39.es/ecma262/#sec-tostring
8
10
  */
9
11
  function ToString(o) {
10
- if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
11
- return String(o);
12
+ if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
13
+ return StringConstructor(o);
12
14
  }
13
15
  // node_modules/.aspect_rules_js/@formatjs+fast-memoize@0.0.0/node_modules/@formatjs/fast-memoize/index.js
16
+ const apply = Reflect.apply;
17
+ const bind = Function.prototype.bind;
18
+ const slice = Array.prototype.slice;
19
+ const stringify = JSON.stringify;
20
+ const create = Object.create;
21
+ const defineProperty$1 = Object.defineProperty;
22
+ const setPrototypeOf = Object.setPrototypeOf;
14
23
  function memoize(fn, options) {
15
24
  const cache = options && options.cache ? options.cache : cacheDefault;
16
25
  const serializer = options && options.serializer ? options.serializer : serializerDefault;
@@ -26,23 +35,29 @@ function monadic(fn, cache, serializer, arg) {
26
35
  const cacheKey = isPrimitive(arg) ? arg : serializer(arg);
27
36
  let computedValue = cache.get(cacheKey);
28
37
  if (typeof computedValue === "undefined") {
29
- computedValue = fn.call(this, arg);
38
+ computedValue = apply(fn, this, [arg]);
30
39
  cache.set(cacheKey, computedValue);
31
40
  }
32
41
  return computedValue;
33
42
  }
34
43
  function variadic(fn, cache, serializer) {
35
- const args = Array.prototype.slice.call(arguments, 3);
44
+ const args = apply(slice, arguments, [3]);
45
+ if (serializer === serializerDefault) setPrototypeOf(args, null);
36
46
  const cacheKey = serializer(args);
37
47
  let computedValue = cache.get(cacheKey);
38
48
  if (typeof computedValue === "undefined") {
39
- computedValue = fn.apply(this, args);
49
+ computedValue = apply(fn, this, args);
40
50
  cache.set(cacheKey, computedValue);
41
51
  }
42
52
  return computedValue;
43
53
  }
44
54
  function assemble(fn, context, strategy, cache, serialize) {
45
- return strategy.bind(context, fn, cache, serialize);
55
+ return apply(bind, strategy, [
56
+ context,
57
+ fn,
58
+ cache,
59
+ serialize
60
+ ]);
46
61
  }
47
62
  function strategyDefault(fn, options) {
48
63
  const strategy = fn.length === 1 ? monadic : variadic;
@@ -55,11 +70,18 @@ function strategyMonadic(fn, options) {
55
70
  return assemble(fn, this, monadic, options.cache.create(), options.serializer);
56
71
  }
57
72
  const serializerDefault = function() {
58
- return JSON.stringify(arguments);
73
+ setPrototypeOf(arguments, null);
74
+ return stringify(arguments);
59
75
  };
60
76
  var ObjectWithoutPrototypeCache = class {
61
77
  constructor() {
62
- this.cache = Object.create(null);
78
+ defineProperty$1(this, "cache", {
79
+ __proto__: null,
80
+ value: create(null),
81
+ writable: true,
82
+ enumerable: true,
83
+ configurable: true
84
+ });
63
85
  }
64
86
  get(key) {
65
87
  return this.cache[key];
@@ -461,6 +483,13 @@ function isSupportedCollation(collation) {
461
483
  function getSupportedCollations() {
462
484
  return collations.filter(isSupportedCollation).sort();
463
485
  }
486
+ Number.isInteger;
487
+ Number.isFinite;
488
+ Number.isSafeInteger;
489
+ Array.prototype.every;
490
+ Array.prototype.some;
491
+ Array.prototype.includes;
492
+ Array.prototype.indexOf;
464
493
  // packages/ecma402-abstract/utils.js
465
494
  function defineProperty(target, name, { value }) {
466
495
  Object.defineProperty(target, name, {
@@ -477,11 +506,56 @@ function ensureIntl() {
477
506
  writable: true,
478
507
  value: {}
479
508
  });
509
+ if (providerIntl === void 0) providerIntl = Intl;
480
510
  return Intl;
481
511
  }
482
512
  const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
483
513
  memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
484
514
  memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
515
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
516
+ strategies.variadic;
517
+ let providerIntl = globalThis.Intl;
518
+ function ownIntlProvider(name) {
519
+ const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
520
+ return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
521
+ }
522
+ let numberFormatProvider = ownIntlProvider("NumberFormat");
523
+ let listFormatProvider = ownIntlProvider("ListFormat");
524
+ const getFormatterPrototype = Object.getPrototypeOf;
525
+ const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
526
+ const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
527
+ const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
528
+ const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
529
+ const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
530
+ const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
531
+ function findFormatterPartsMethod(Constructor) {
532
+ const cached = getPartsMethod(Constructor);
533
+ if (cached) return cached;
534
+ let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
535
+ while (prototype != null) {
536
+ const inherited = getPartsOwner(prototype);
537
+ if (inherited) {
538
+ setPartsMethod(Constructor, inherited);
539
+ return inherited;
540
+ }
541
+ const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
542
+ const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
543
+ if (value && typeof value.value === "function") {
544
+ setPartsMethod(Constructor, value.value);
545
+ setPartsOwner(prototype, value.value);
546
+ return value.value;
547
+ }
548
+ prototype = getFormatterPrototype(prototype);
549
+ }
550
+ }
551
+ if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
552
+ if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
553
+ const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
554
+ numberFormatMemoizers.get.bind(numberFormatMemoizers);
555
+ numberFormatMemoizers.set.bind(numberFormatMemoizers);
556
+ const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
557
+ listFormatMemoizers.get.bind(listFormatMemoizers);
558
+ listFormatMemoizers.set.bind(listFormatMemoizers);
485
559
  // node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-values@0.0.0/node_modules/@formatjs_generated/cldr.supported-values/currencies.js
486
560
  const currencies = [
487
561
  "ADP",
@@ -1109,7 +1183,6 @@ const timezones = [
1109
1183
  "America/Montserrat",
1110
1184
  "America/Nassau",
1111
1185
  "America/New_York",
1112
- "America/Nipigon",
1113
1186
  "America/Nome",
1114
1187
  "America/Noronha",
1115
1188
  "America/North_Dakota/Beulah",
@@ -1118,7 +1191,6 @@ const timezones = [
1118
1191
  "America/Nuuk",
1119
1192
  "America/Ojinaga",
1120
1193
  "America/Panama",
1121
- "America/Pangnirtung",
1122
1194
  "America/Paramaribo",
1123
1195
  "America/Phoenix",
1124
1196
  "America/Port-au-Prince",
@@ -1126,7 +1198,6 @@ const timezones = [
1126
1198
  "America/Porto_Velho",
1127
1199
  "America/Puerto_Rico",
1128
1200
  "America/Punta_Arenas",
1129
- "America/Rainy_River",
1130
1201
  "America/Rankin_Inlet",
1131
1202
  "America/Recife",
1132
1203
  "America/Regina",
@@ -1147,7 +1218,6 @@ const timezones = [
1147
1218
  "America/Swift_Current",
1148
1219
  "America/Tegucigalpa",
1149
1220
  "America/Thule",
1150
- "America/Thunder_Bay",
1151
1221
  "America/Tijuana",
1152
1222
  "America/Toronto",
1153
1223
  "America/Tortola",
@@ -1155,7 +1225,6 @@ const timezones = [
1155
1225
  "America/Whitehorse",
1156
1226
  "America/Winnipeg",
1157
1227
  "America/Yakutat",
1158
- "America/Yellowknife",
1159
1228
  "Antarctica/Casey",
1160
1229
  "Antarctica/Davis",
1161
1230
  "Antarctica/DumontDUrville",
@@ -1185,7 +1254,6 @@ const timezones = [
1185
1254
  "Asia/Bishkek",
1186
1255
  "Asia/Brunei",
1187
1256
  "Asia/Chita",
1188
- "Asia/Choibalsan",
1189
1257
  "Asia/Colombo",
1190
1258
  "Asia/Damascus",
1191
1259
  "Asia/Dhaka",
@@ -1264,7 +1332,6 @@ const timezones = [
1264
1332
  "Australia/Adelaide",
1265
1333
  "Australia/Brisbane",
1266
1334
  "Australia/Broken_Hill",
1267
- "Australia/Currie",
1268
1335
  "Australia/Darwin",
1269
1336
  "Australia/Eucla",
1270
1337
  "Australia/Hobart",
@@ -1351,7 +1418,6 @@ const timezones = [
1351
1418
  "Europe/Tallinn",
1352
1419
  "Europe/Tirane",
1353
1420
  "Europe/Ulyanovsk",
1354
- "Europe/Uzhgorod",
1355
1421
  "Europe/Vaduz",
1356
1422
  "Europe/Vatican",
1357
1423
  "Europe/Vienna",
@@ -1359,7 +1425,6 @@ const timezones = [
1359
1425
  "Europe/Volgograd",
1360
1426
  "Europe/Warsaw",
1361
1427
  "Europe/Zagreb",
1362
- "Europe/Zaporozhye",
1363
1428
  "Europe/Zurich",
1364
1429
  "Indian/Antananarivo",
1365
1430
  "Indian/Chagos",
@@ -1423,7 +1488,8 @@ const timezones = [
1423
1488
  */
1424
1489
  function isSupportedTimeZone(timeZone) {
1425
1490
  try {
1426
- return createMemoizedDateTimeFormat("en", { timeZone }).resolvedOptions().timeZone === timeZone;
1491
+ createMemoizedDateTimeFormat("en", { timeZone });
1492
+ return true;
1427
1493
  } catch {}
1428
1494
  return false;
1429
1495
  }
package/polyfill.js CHANGED
@@ -4,12 +4,14 @@ function shouldPolyfill() {
4
4
  return typeof Intl === "undefined" || !("supportedValuesOf" in Intl);
5
5
  }
6
6
  // packages/ecma262-abstract/ToString.js
7
+ const StringConstructor = String;
8
+ const TypeErrorConstructor = TypeError;
7
9
  /**
8
10
  * https://tc39.es/ecma262/#sec-tostring
9
11
  */
10
12
  function ToString(o) {
11
- if (typeof o === "symbol") throw TypeError("Cannot convert a Symbol value to a string");
12
- return String(o);
13
+ if (typeof o === "symbol") throw TypeErrorConstructor("Cannot convert a Symbol value to a string");
14
+ return StringConstructor(o);
13
15
  }
14
16
  // packages/intl-supportedvaluesof/memoize.ts
15
17
  /**
@@ -397,6 +399,13 @@ function isSupportedCollation(collation) {
397
399
  function getSupportedCollations() {
398
400
  return collations.filter(isSupportedCollation).sort();
399
401
  }
402
+ Number.isInteger;
403
+ Number.isFinite;
404
+ Number.isSafeInteger;
405
+ Array.prototype.every;
406
+ Array.prototype.some;
407
+ Array.prototype.includes;
408
+ Array.prototype.indexOf;
400
409
  // packages/ecma402-abstract/utils.js
401
410
  function defineProperty(target, name, { value }) {
402
411
  Object.defineProperty(target, name, {
@@ -413,11 +422,56 @@ function ensureIntl() {
413
422
  writable: true,
414
423
  value: {}
415
424
  });
425
+ if (providerIntl === void 0) providerIntl = Intl;
416
426
  return Intl;
417
427
  }
418
428
  const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
419
429
  memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
420
430
  memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
431
+ const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
432
+ strategies.variadic;
433
+ let providerIntl = globalThis.Intl;
434
+ function ownIntlProvider(name) {
435
+ const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
436
+ return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
437
+ }
438
+ let numberFormatProvider = ownIntlProvider("NumberFormat");
439
+ let listFormatProvider = ownIntlProvider("ListFormat");
440
+ const getFormatterPrototype = Object.getPrototypeOf;
441
+ const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
442
+ const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
443
+ const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
444
+ const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
445
+ const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
446
+ const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
447
+ function findFormatterPartsMethod(Constructor) {
448
+ const cached = getPartsMethod(Constructor);
449
+ if (cached) return cached;
450
+ let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
451
+ while (prototype != null) {
452
+ const inherited = getPartsOwner(prototype);
453
+ if (inherited) {
454
+ setPartsMethod(Constructor, inherited);
455
+ return inherited;
456
+ }
457
+ const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
458
+ const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
459
+ if (value && typeof value.value === "function") {
460
+ setPartsMethod(Constructor, value.value);
461
+ setPartsOwner(prototype, value.value);
462
+ return value.value;
463
+ }
464
+ prototype = getFormatterPrototype(prototype);
465
+ }
466
+ }
467
+ if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
468
+ if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
469
+ const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
470
+ numberFormatMemoizers.get.bind(numberFormatMemoizers);
471
+ numberFormatMemoizers.set.bind(numberFormatMemoizers);
472
+ const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
473
+ listFormatMemoizers.get.bind(listFormatMemoizers);
474
+ listFormatMemoizers.set.bind(listFormatMemoizers);
421
475
  // node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-values@0.0.0/node_modules/@formatjs_generated/cldr.supported-values/currencies.js
422
476
  const currencies = [
423
477
  "ADP",
@@ -1045,7 +1099,6 @@ const timezones = [
1045
1099
  "America/Montserrat",
1046
1100
  "America/Nassau",
1047
1101
  "America/New_York",
1048
- "America/Nipigon",
1049
1102
  "America/Nome",
1050
1103
  "America/Noronha",
1051
1104
  "America/North_Dakota/Beulah",
@@ -1054,7 +1107,6 @@ const timezones = [
1054
1107
  "America/Nuuk",
1055
1108
  "America/Ojinaga",
1056
1109
  "America/Panama",
1057
- "America/Pangnirtung",
1058
1110
  "America/Paramaribo",
1059
1111
  "America/Phoenix",
1060
1112
  "America/Port-au-Prince",
@@ -1062,7 +1114,6 @@ const timezones = [
1062
1114
  "America/Porto_Velho",
1063
1115
  "America/Puerto_Rico",
1064
1116
  "America/Punta_Arenas",
1065
- "America/Rainy_River",
1066
1117
  "America/Rankin_Inlet",
1067
1118
  "America/Recife",
1068
1119
  "America/Regina",
@@ -1083,7 +1134,6 @@ const timezones = [
1083
1134
  "America/Swift_Current",
1084
1135
  "America/Tegucigalpa",
1085
1136
  "America/Thule",
1086
- "America/Thunder_Bay",
1087
1137
  "America/Tijuana",
1088
1138
  "America/Toronto",
1089
1139
  "America/Tortola",
@@ -1091,7 +1141,6 @@ const timezones = [
1091
1141
  "America/Whitehorse",
1092
1142
  "America/Winnipeg",
1093
1143
  "America/Yakutat",
1094
- "America/Yellowknife",
1095
1144
  "Antarctica/Casey",
1096
1145
  "Antarctica/Davis",
1097
1146
  "Antarctica/DumontDUrville",
@@ -1121,7 +1170,6 @@ const timezones = [
1121
1170
  "Asia/Bishkek",
1122
1171
  "Asia/Brunei",
1123
1172
  "Asia/Chita",
1124
- "Asia/Choibalsan",
1125
1173
  "Asia/Colombo",
1126
1174
  "Asia/Damascus",
1127
1175
  "Asia/Dhaka",
@@ -1200,7 +1248,6 @@ const timezones = [
1200
1248
  "Australia/Adelaide",
1201
1249
  "Australia/Brisbane",
1202
1250
  "Australia/Broken_Hill",
1203
- "Australia/Currie",
1204
1251
  "Australia/Darwin",
1205
1252
  "Australia/Eucla",
1206
1253
  "Australia/Hobart",
@@ -1287,7 +1334,6 @@ const timezones = [
1287
1334
  "Europe/Tallinn",
1288
1335
  "Europe/Tirane",
1289
1336
  "Europe/Ulyanovsk",
1290
- "Europe/Uzhgorod",
1291
1337
  "Europe/Vaduz",
1292
1338
  "Europe/Vatican",
1293
1339
  "Europe/Vienna",
@@ -1295,7 +1341,6 @@ const timezones = [
1295
1341
  "Europe/Volgograd",
1296
1342
  "Europe/Warsaw",
1297
1343
  "Europe/Zagreb",
1298
- "Europe/Zaporozhye",
1299
1344
  "Europe/Zurich",
1300
1345
  "Indian/Antananarivo",
1301
1346
  "Indian/Chagos",
@@ -1359,7 +1404,8 @@ const timezones = [
1359
1404
  */
1360
1405
  function isSupportedTimeZone(timeZone) {
1361
1406
  try {
1362
- return createMemoizedDateTimeFormat("en", { timeZone }).resolvedOptions().timeZone === timeZone;
1407
+ createMemoizedDateTimeFormat("en", { timeZone });
1408
+ return true;
1363
1409
  } catch {}
1364
1410
  return false;
1365
1411
  }