@formatjs/intl-getcanonicallocales 3.3.0 → 3.4.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.
@@ -1,4 +1 @@
1
- //#region packages/intl-getcanonicallocales/should-polyfill.d.ts
2
- export declare function shouldPolyfill(): boolean;
3
- //#endregion
4
- //# sourceMappingURL=should-polyfill.d.ts.map
1
+ export declare function shouldPolyfill(): boolean;
@@ -1,8 +1,13 @@
1
- //#region packages/intl-getcanonicallocales/should-polyfill.ts
1
+ // packages/intl-getcanonicallocales/should-polyfill.ts
2
2
  function shouldPolyfill() {
3
- return typeof Intl === "undefined" || !("getCanonicalLocales" in Intl) || Intl.getCanonicalLocales("und-x-private")[0] === "x-private";
3
+ if (typeof Intl === "undefined" || typeof Intl.getCanonicalLocales !== "function") return true;
4
+ try {
5
+ const canonicalize = Intl.getCanonicalLocales;
6
+ return canonicalize("und-x-private")[0] !== "und-x-private" || canonicalize("en-u-aa-yes")[0] !== "en-u-aa-yes" || canonicalize("en-u-kn-yes")[0] !== "en-u-kn";
7
+ } catch {
8
+ return true;
9
+ }
4
10
  }
5
- //#endregion
6
11
  export { shouldPolyfill };
7
12
 
8
13
  //# sourceMappingURL=should-polyfill.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"should-polyfill.js","names":[],"sources":["sources/packages/intl-getcanonicallocales/should-polyfill.ts"],"sourcesContent":["export function shouldPolyfill(): boolean {\n return (\n typeof Intl === 'undefined' ||\n !('getCanonicalLocales' in Intl) ||\n // Native Intl.getCanonicalLocales is just buggy\n // https://bugs.chromium.org/p/v8/issues/detail?id=10682\n ((Intl as any).getCanonicalLocales as any)('und-x-private')[0] ===\n 'x-private'\n )\n}\n"],"mappings":";AAAA,SAAgB,iBAA0B;CACxC,OACE,OAAO,SAAS,eAChB,EAAE,yBAAyB,SAGzB,KAAa,oBAA4B,eAAe,CAAC,CAAC,OAC1D;AAEN"}
1
+ {"version":3,"file":"should-polyfill.js","names":[],"sources":["sources/packages/intl-getcanonicallocales/should-polyfill.ts"],"sourcesContent":["export function shouldPolyfill(): boolean {\n if (\n typeof Intl === 'undefined' ||\n typeof (Intl as any).getCanonicalLocales !== 'function'\n ) {\n return true\n }\n try {\n const canonicalize = (Intl as any).getCanonicalLocales\n return (\n // https://bugs.chromium.org/p/v8/issues/detail?id=10682\n canonicalize('und-x-private')[0] !== 'und-x-private' ||\n // ECMA-402 canonicalizes aliases by key; only whole \"true\" values disappear.\n // https://tc39.es/ecma402/#sec-canonicalizeunicodelocaleid\n canonicalize('en-u-aa-yes')[0] !== 'en-u-aa-yes' ||\n canonicalize('en-u-kn-yes')[0] !== 'en-u-kn'\n )\n } catch {\n return true\n }\n}\n"],"mappings":";AAAA,SAAgB,iBAA0B;CACxC,IACE,OAAO,SAAS,eAChB,OAAQ,KAAa,wBAAwB,YAE7C,OAAO;CAET,IAAI;EACF,MAAM,eAAgB,KAAa;EACnC,OAEE,aAAa,eAAe,CAAC,CAAC,OAAO,mBAGrC,aAAa,aAAa,CAAC,CAAC,OAAO,iBACnC,aAAa,aAAa,CAAC,CAAC,OAAO;CAEvC,QAAQ;EACN,OAAO;CACT;AACF"}