@formatjs/intl-getcanonicallocales 3.1.1 → 3.1.2

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export declare function getCanonicalLocales(locales?: string[] | string): string[];
2
- export * from './src/emitter.js';
3
- export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId, } from './src/parser.js';
4
- export * from './src/types.js';
5
- export * from './src/likelySubtags.generated.js';
2
+ export * from "./src/emitter.js";
3
+ export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId } from "./src/parser.js";
4
+ export * from "./src/types.js";
5
+ export * from "./src/likelySubtags.generated.js";
package/index.js CHANGED
@@ -1,31 +1,30 @@
1
- import { CanonicalizeUnicodeLocaleId } from './src/canonicalizer.js';
2
- import { emitUnicodeLocaleId } from './src/emitter.js';
3
- import { parseUnicodeLocaleId } from './src/parser.js';
1
+ import { CanonicalizeUnicodeLocaleId } from "./src/canonicalizer.js";
2
+ import { emitUnicodeLocaleId } from "./src/emitter.js";
3
+ import { parseUnicodeLocaleId } from "./src/parser.js";
4
4
  /**
5
- * https://tc39.es/ecma402/#sec-canonicalizelocalelist
6
- * @param locales
7
- */
5
+ * https://tc39.es/ecma402/#sec-canonicalizelocalelist
6
+ * @param locales
7
+ */
8
8
  function CanonicalizeLocaleList(locales) {
9
- if (locales === undefined) {
10
- return [];
11
- }
12
- var seen = [];
13
- if (typeof locales === 'string') {
14
- locales = [locales];
15
- }
16
- for (var _i = 0, locales_1 = locales; _i < locales_1.length; _i++) {
17
- var locale = locales_1[_i];
18
- var canonicalizedTag = emitUnicodeLocaleId(CanonicalizeUnicodeLocaleId(parseUnicodeLocaleId(locale)));
19
- if (seen.indexOf(canonicalizedTag) < 0) {
20
- seen.push(canonicalizedTag);
21
- }
22
- }
23
- return seen;
9
+ if (locales === undefined) {
10
+ return [];
11
+ }
12
+ const seen = [];
13
+ if (typeof locales === "string") {
14
+ locales = [locales];
15
+ }
16
+ for (const locale of locales) {
17
+ const canonicalizedTag = emitUnicodeLocaleId(CanonicalizeUnicodeLocaleId(parseUnicodeLocaleId(locale)));
18
+ if (seen.indexOf(canonicalizedTag) < 0) {
19
+ seen.push(canonicalizedTag);
20
+ }
21
+ }
22
+ return seen;
24
23
  }
25
24
  export function getCanonicalLocales(locales) {
26
- return CanonicalizeLocaleList(locales);
25
+ return CanonicalizeLocaleList(locales);
27
26
  }
28
- export * from './src/emitter.js';
29
- export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId, } from './src/parser.js';
30
- export * from './src/types.js';
31
- export * from './src/likelySubtags.generated.js';
27
+ export * from "./src/emitter.js";
28
+ export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId } from "./src/parser.js";
29
+ export * from "./src/types.js";
30
+ export * from "./src/likelySubtags.generated.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formatjs/intl-getcanonicallocales",
3
3
  "description": "Intl.getCanonicalLocales polyfill",
4
- "version": "3.1.1",
4
+ "version": "3.1.2",
5
5
  "license": "MIT",
6
6
  "author": "Long Ho <holevietlong@gmail.com>",
7
7
  "type": "module",
package/polyfill-force.js CHANGED
@@ -1,21 +1,15 @@
1
- import { getCanonicalLocales } from './index.js';
2
- if (typeof Intl === 'undefined') {
3
- if (typeof window !== 'undefined') {
4
- Object.defineProperty(window, 'Intl', {
5
- value: {},
6
- });
7
- // @ts-ignore we don't include @types/node so global isn't a thing
8
- }
9
- else if (typeof global !== 'undefined') {
10
- // @ts-ignore we don't include @types/node so global isn't a thing
11
- Object.defineProperty(global, 'Intl', {
12
- value: {},
13
- });
14
- }
1
+ import { getCanonicalLocales } from "./index.js";
2
+ if (typeof Intl === "undefined") {
3
+ if (typeof window !== "undefined") {
4
+ Object.defineProperty(window, "Intl", { value: {} });
5
+ } else if (typeof global !== "undefined") {
6
+ // @ts-ignore we don't include @types/node so global isn't a thing
7
+ Object.defineProperty(global, "Intl", { value: {} });
8
+ }
15
9
  }
16
- Object.defineProperty(Intl, 'getCanonicalLocales', {
17
- value: getCanonicalLocales,
18
- writable: true,
19
- enumerable: false,
20
- configurable: true,
10
+ Object.defineProperty(Intl, "getCanonicalLocales", {
11
+ value: getCanonicalLocales,
12
+ writable: true,
13
+ enumerable: false,
14
+ configurable: true
21
15
  });
package/polyfill.js CHANGED
@@ -1,24 +1,18 @@
1
- import { getCanonicalLocales } from './index.js';
2
- import { shouldPolyfill } from './should-polyfill.js';
3
- if (typeof Intl === 'undefined') {
4
- if (typeof window !== 'undefined') {
5
- Object.defineProperty(window, 'Intl', {
6
- value: {},
7
- });
8
- // @ts-ignore we don't include @types/node so global isn't a thing
9
- }
10
- else if (typeof global !== 'undefined') {
11
- // @ts-ignore we don't include @types/node so global isn't a thing
12
- Object.defineProperty(global, 'Intl', {
13
- value: {},
14
- });
15
- }
1
+ import { getCanonicalLocales } from "./index.js";
2
+ import { shouldPolyfill } from "./should-polyfill.js";
3
+ if (typeof Intl === "undefined") {
4
+ if (typeof window !== "undefined") {
5
+ Object.defineProperty(window, "Intl", { value: {} });
6
+ } else if (typeof global !== "undefined") {
7
+ // @ts-ignore we don't include @types/node so global isn't a thing
8
+ Object.defineProperty(global, "Intl", { value: {} });
9
+ }
16
10
  }
17
11
  if (shouldPolyfill()) {
18
- Object.defineProperty(Intl, 'getCanonicalLocales', {
19
- value: getCanonicalLocales,
20
- writable: true,
21
- enumerable: false,
22
- configurable: true,
23
- });
12
+ Object.defineProperty(Intl, "getCanonicalLocales", {
13
+ value: getCanonicalLocales,
14
+ writable: true,
15
+ enumerable: false,
16
+ configurable: true
17
+ });
24
18
  }
@@ -1,8 +1,3 @@
1
1
  export function shouldPolyfill() {
2
- return (typeof Intl === 'undefined' ||
3
- !('getCanonicalLocales' in Intl) ||
4
- // Native Intl.getCanonicalLocales is just buggy
5
- // https://bugs.chromium.org/p/v8/issues/detail?id=10682
6
- Intl.getCanonicalLocales('und-x-private')[0] ===
7
- 'x-private');
2
+ return typeof Intl === "undefined" || !("getCanonicalLocales" in Intl) || Intl.getCanonicalLocales("und-x-private")[0] === "x-private";
8
3
  }
@@ -1,3 +1,5 @@
1
+ /* @generated */
2
+ // prettier-ignore
1
3
  export declare const languageAlias: Record<string, string>;
2
4
  export declare const territoryAlias: Record<string, string>;
3
5
  export declare const scriptAlias: Record<string, string>;