@formatjs/intl-supportedvaluesof 3.1.0 → 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.1.0",
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",