@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/index.js +55 -2
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/polyfill-force.js +56 -2
- package/polyfill-force.js.map +1 -1
- package/polyfill.iife.js +82 -8
- package/polyfill.js +56 -2
- package/polyfill.js.map +1 -1
package/index.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
|
|
8
|
-
return
|
|
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,10 +395,61 @@ 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
|
const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
398
407
|
memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
|
|
399
408
|
memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
|
|
409
|
+
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
410
|
+
strategies.variadic;
|
|
411
|
+
let providerIntl = globalThis.Intl;
|
|
412
|
+
function ownIntlProvider(name) {
|
|
413
|
+
const descriptor = providerIntl && getOwnPropertyDescriptor(providerIntl, name);
|
|
414
|
+
return (descriptor && getOwnPropertyDescriptor(descriptor, "value"))?.value;
|
|
415
|
+
}
|
|
416
|
+
let numberFormatProvider = ownIntlProvider("NumberFormat");
|
|
417
|
+
let listFormatProvider = ownIntlProvider("ListFormat");
|
|
418
|
+
const getFormatterPrototype = Object.getPrototypeOf;
|
|
419
|
+
const formatterPartsMethods = /* @__PURE__ */ new WeakMap();
|
|
420
|
+
const formatterPartsOwners = /* @__PURE__ */ new WeakMap();
|
|
421
|
+
const getPartsMethod = formatterPartsMethods.get.bind(formatterPartsMethods);
|
|
422
|
+
const setPartsMethod = formatterPartsMethods.set.bind(formatterPartsMethods);
|
|
423
|
+
const getPartsOwner = formatterPartsOwners.get.bind(formatterPartsOwners);
|
|
424
|
+
const setPartsOwner = formatterPartsOwners.set.bind(formatterPartsOwners);
|
|
425
|
+
function findFormatterPartsMethod(Constructor) {
|
|
426
|
+
const cached = getPartsMethod(Constructor);
|
|
427
|
+
if (cached) return cached;
|
|
428
|
+
let prototype = getOwnPropertyDescriptor(Constructor, "prototype")?.value;
|
|
429
|
+
while (prototype != null) {
|
|
430
|
+
const inherited = getPartsOwner(prototype);
|
|
431
|
+
if (inherited) {
|
|
432
|
+
setPartsMethod(Constructor, inherited);
|
|
433
|
+
return inherited;
|
|
434
|
+
}
|
|
435
|
+
const descriptor = getOwnPropertyDescriptor(prototype, "formatToParts");
|
|
436
|
+
const value = descriptor && getOwnPropertyDescriptor(descriptor, "value");
|
|
437
|
+
if (value && typeof value.value === "function") {
|
|
438
|
+
setPartsMethod(Constructor, value.value);
|
|
439
|
+
setPartsOwner(prototype, value.value);
|
|
440
|
+
return value.value;
|
|
441
|
+
}
|
|
442
|
+
prototype = getFormatterPrototype(prototype);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
if (typeof numberFormatProvider === "function") findFormatterPartsMethod(numberFormatProvider);
|
|
446
|
+
if (typeof listFormatProvider === "function") findFormatterPartsMethod(listFormatProvider);
|
|
447
|
+
const numberFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
448
|
+
numberFormatMemoizers.get.bind(numberFormatMemoizers);
|
|
449
|
+
numberFormatMemoizers.set.bind(numberFormatMemoizers);
|
|
450
|
+
const listFormatMemoizers = /* @__PURE__ */ new WeakMap();
|
|
451
|
+
listFormatMemoizers.get.bind(listFormatMemoizers);
|
|
452
|
+
listFormatMemoizers.set.bind(listFormatMemoizers);
|
|
400
453
|
// node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-values@0.0.0/node_modules/@formatjs_generated/cldr.supported-values/currencies.js
|
|
401
454
|
const currencies = [
|
|
402
455
|
"ADP",
|