@formatjs/intl-getcanonicallocales 2.5.4 → 2.5.6

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,30 +1,25 @@
1
1
  {
2
2
  "name": "@formatjs/intl-getcanonicallocales",
3
- "version": "2.5.4",
4
3
  "description": "Intl.getCanonicalLocales polyfill",
4
+ "version": "2.5.6",
5
+ "license": "MIT",
6
+ "author": "Long Ho <holevietlong@gmail.com>",
7
+ "types": "index.d.ts",
8
+ "dependencies": {
9
+ "tslib": "^2.8.0"
10
+ },
11
+ "bugs": "https://github.com/formatjs/formatjs/issues",
12
+ "homepage": "https://github.com/formatjs/formatjs#readme",
5
13
  "keywords": [
14
+ "ecma402",
15
+ "formatjs",
16
+ "getCanonicalLocales",
17
+ "i18n",
6
18
  "intl",
7
19
  "locale",
8
- "formatjs",
9
20
  "react-intl",
10
- "i18n",
11
- "ecma402",
12
- "tc39",
13
- "getCanonicalLocales"
21
+ "tc39"
14
22
  ],
15
- "author": "Long Ho <holevietlong@gmail.com>",
16
- "homepage": "https://github.com/formatjs/formatjs#readme",
17
- "license": "MIT",
18
23
  "main": "index.js",
19
- "types": "index.d.ts",
20
- "repository": {
21
- "type": "git",
22
- "url": "git+https://github.com/formatjs/formatjs.git"
23
- },
24
- "bugs": {
25
- "url": "https://github.com/formatjs/formatjs/issues"
26
- },
27
- "dependencies": {
28
- "tslib": "2"
29
- }
24
+ "repository": "formatjs/formatjs.git"
30
25
  }
package/lib/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export declare function getCanonicalLocales(locales?: string[] | string): string[];
2
- export { parseUnicodeLocaleId, parseUnicodeLanguageId, isStructurallyValidLanguageTag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, isUnicodeLanguageSubtag, } from './src/parser';
3
- export * from './src/types';
4
- export * from './src/emitter';
5
- export * from './src/likelySubtags.generated';
package/lib/index.js DELETED
@@ -1,31 +0,0 @@
1
- import { parseUnicodeLocaleId } from './src/parser';
2
- import { emitUnicodeLocaleId } from './src/emitter';
3
- import { canonicalizeUnicodeLocaleId } from './src/canonicalizer';
4
- /**
5
- * https://tc39.es/ecma402/#sec-canonicalizelocalelist
6
- * @param locales
7
- */
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;
24
- }
25
- export function getCanonicalLocales(locales) {
26
- return CanonicalizeLocaleList(locales);
27
- }
28
- export { parseUnicodeLocaleId, parseUnicodeLanguageId, isStructurallyValidLanguageTag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, isUnicodeLanguageSubtag, } from './src/parser';
29
- export * from './src/types';
30
- export * from './src/emitter';
31
- export * from './src/likelySubtags.generated';
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import { getCanonicalLocales } from './';
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
- }
15
- }
16
- Object.defineProperty(Intl, 'getCanonicalLocales', {
17
- value: getCanonicalLocales,
18
- writable: true,
19
- enumerable: false,
20
- configurable: true,
21
- });
package/lib/polyfill.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/lib/polyfill.js DELETED
@@ -1,24 +0,0 @@
1
- import { getCanonicalLocales } from './';
2
- import { shouldPolyfill } from './should-polyfill';
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
- }
16
- }
17
- if (shouldPolyfill()) {
18
- Object.defineProperty(Intl, 'getCanonicalLocales', {
19
- value: getCanonicalLocales,
20
- writable: true,
21
- enumerable: false,
22
- configurable: true,
23
- });
24
- }
@@ -1 +0,0 @@
1
- export declare function shouldPolyfill(): boolean;
@@ -1,8 +0,0 @@
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');
8
- }
@@ -1,4 +0,0 @@
1
- export declare const languageAlias: Record<string, string>;
2
- export declare const territoryAlias: Record<string, string>;
3
- export declare const scriptAlias: Record<string, string>;
4
- export declare const variantAlias: Record<string, string>;