@formatjs/intl-getcanonicallocales 2.5.2 → 2.5.3

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 { parseUnicodeLocaleId, parseUnicodeLanguageId, isStructurallyValidLanguageTag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, isUnicodeLanguageSubtag, } from './src/parser';
3
- export * from './src/types';
4
2
  export * from './src/emitter';
3
+ export { isStructurallyValidLanguageTag, isUnicodeLanguageSubtag, isUnicodeRegionSubtag, isUnicodeScriptSubtag, parseUnicodeLanguageId, parseUnicodeLocaleId, } from './src/parser';
4
+ export * from './src/types';
5
5
  export * from './src/likelySubtags.generated';
package/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isUnicodeLanguageSubtag = exports.isUnicodeScriptSubtag = exports.isUnicodeRegionSubtag = exports.isStructurallyValidLanguageTag = exports.parseUnicodeLanguageId = exports.parseUnicodeLocaleId = void 0;
3
+ exports.parseUnicodeLocaleId = exports.parseUnicodeLanguageId = exports.isUnicodeScriptSubtag = exports.isUnicodeRegionSubtag = exports.isUnicodeLanguageSubtag = exports.isStructurallyValidLanguageTag = void 0;
4
4
  exports.getCanonicalLocales = getCanonicalLocales;
5
5
  var tslib_1 = require("tslib");
6
- var parser_1 = require("./src/parser");
7
- var emitter_1 = require("./src/emitter");
8
6
  var canonicalizer_1 = require("./src/canonicalizer");
7
+ var emitter_1 = require("./src/emitter");
8
+ var parser_1 = require("./src/parser");
9
9
  /**
10
10
  * https://tc39.es/ecma402/#sec-canonicalizelocalelist
11
11
  * @param locales
@@ -20,7 +20,7 @@ function CanonicalizeLocaleList(locales) {
20
20
  }
21
21
  for (var _i = 0, locales_1 = locales; _i < locales_1.length; _i++) {
22
22
  var locale = locales_1[_i];
23
- var canonicalizedTag = (0, emitter_1.emitUnicodeLocaleId)((0, canonicalizer_1.canonicalizeUnicodeLocaleId)((0, parser_1.parseUnicodeLocaleId)(locale)));
23
+ var canonicalizedTag = (0, emitter_1.emitUnicodeLocaleId)((0, canonicalizer_1.CanonicalizeUnicodeLocaleId)((0, parser_1.parseUnicodeLocaleId)(locale)));
24
24
  if (seen.indexOf(canonicalizedTag) < 0) {
25
25
  seen.push(canonicalizedTag);
26
26
  }
@@ -30,14 +30,13 @@ function CanonicalizeLocaleList(locales) {
30
30
  function getCanonicalLocales(locales) {
31
31
  return CanonicalizeLocaleList(locales);
32
32
  }
33
+ tslib_1.__exportStar(require("./src/emitter"), exports);
33
34
  var parser_2 = require("./src/parser");
34
- Object.defineProperty(exports, "parseUnicodeLocaleId", { enumerable: true, get: function () { return parser_2.parseUnicodeLocaleId; } });
35
- Object.defineProperty(exports, "parseUnicodeLanguageId", { enumerable: true, get: function () { return parser_2.parseUnicodeLanguageId; } });
36
35
  Object.defineProperty(exports, "isStructurallyValidLanguageTag", { enumerable: true, get: function () { return parser_2.isStructurallyValidLanguageTag; } });
36
+ Object.defineProperty(exports, "isUnicodeLanguageSubtag", { enumerable: true, get: function () { return parser_2.isUnicodeLanguageSubtag; } });
37
37
  Object.defineProperty(exports, "isUnicodeRegionSubtag", { enumerable: true, get: function () { return parser_2.isUnicodeRegionSubtag; } });
38
38
  Object.defineProperty(exports, "isUnicodeScriptSubtag", { enumerable: true, get: function () { return parser_2.isUnicodeScriptSubtag; } });
39
- Object.defineProperty(exports, "isUnicodeLanguageSubtag", { enumerable: true, get: function () { return parser_2.isUnicodeLanguageSubtag; } });
39
+ Object.defineProperty(exports, "parseUnicodeLanguageId", { enumerable: true, get: function () { return parser_2.parseUnicodeLanguageId; } });
40
+ Object.defineProperty(exports, "parseUnicodeLocaleId", { enumerable: true, get: function () { return parser_2.parseUnicodeLocaleId; } });
40
41
  tslib_1.__exportStar(require("./src/types"), exports);
41
- tslib_1.__exportStar(require("./src/emitter"), exports);
42
42
  tslib_1.__exportStar(require("./src/likelySubtags.generated"), exports);
43
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-getcanonicallocales",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Intl.getCanonicalLocales polyfill",
5
5
  "keywords": [
6
6
  "intl",
package/polyfill-force.js CHANGED
@@ -21,4 +21,3 @@ Object.defineProperty(Intl, 'getCanonicalLocales', {
21
21
  enumerable: false,
22
22
  configurable: true,
23
23
  });
24
- //# sourceMappingURL=polyfill-force.js.map
package/polyfill.iife.js CHANGED
@@ -16,260 +16,6 @@
16
16
  return a;
17
17
  };
18
18
 
19
- // packages/intl-getcanonicallocales/src/parser.ts
20
- var ALPHANUM_1_8 = /^[a-z0-9]{1,8}$/i;
21
- var ALPHANUM_2_8 = /^[a-z0-9]{2,8}$/i;
22
- var ALPHANUM_3_8 = /^[a-z0-9]{3,8}$/i;
23
- var KEY_REGEX = /^[a-z0-9][a-z]$/i;
24
- var TYPE_REGEX = /^[a-z0-9]{3,8}$/i;
25
- var ALPHA_4 = /^[a-z]{4}$/i;
26
- var OTHER_EXTENSION_TYPE = /^[0-9a-svwyz]$/i;
27
- var UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
28
- var UNICODE_VARIANT_SUBTAG_REGEX = /^([a-z0-9]{5,8}|[0-9][a-z0-9]{3})$/i;
29
- var UNICODE_LANGUAGE_SUBTAG_REGEX = /^([a-z]{2,3}|[a-z]{5,8})$/i;
30
- var TKEY_REGEX = /^[a-z][0-9]$/i;
31
- var SEPARATOR = "-";
32
- function isUnicodeLanguageSubtag(lang) {
33
- return UNICODE_LANGUAGE_SUBTAG_REGEX.test(lang);
34
- }
35
- function isUnicodeRegionSubtag(region) {
36
- return UNICODE_REGION_SUBTAG_REGEX.test(region);
37
- }
38
- function isUnicodeScriptSubtag(script) {
39
- return ALPHA_4.test(script);
40
- }
41
- function isUnicodeVariantSubtag(variant) {
42
- return UNICODE_VARIANT_SUBTAG_REGEX.test(variant);
43
- }
44
- function parseUnicodeLanguageId(chunks) {
45
- if (typeof chunks === "string") {
46
- chunks = chunks.split(SEPARATOR);
47
- }
48
- const lang = chunks.shift();
49
- if (!lang) {
50
- throw new RangeError("Missing unicode_language_subtag");
51
- }
52
- if (lang === "root") {
53
- return { lang: "root", variants: [] };
54
- }
55
- if (!isUnicodeLanguageSubtag(lang)) {
56
- throw new RangeError("Malformed unicode_language_subtag");
57
- }
58
- let script;
59
- if (chunks.length && isUnicodeScriptSubtag(chunks[0])) {
60
- script = chunks.shift();
61
- }
62
- let region;
63
- if (chunks.length && isUnicodeRegionSubtag(chunks[0])) {
64
- region = chunks.shift();
65
- }
66
- const variants = {};
67
- while (chunks.length && isUnicodeVariantSubtag(chunks[0])) {
68
- const variant = chunks.shift();
69
- if (variant in variants) {
70
- throw new RangeError(`Duplicate variant "${variant}"`);
71
- }
72
- variants[variant] = 1;
73
- }
74
- return {
75
- lang,
76
- script,
77
- region,
78
- variants: Object.keys(variants)
79
- };
80
- }
81
- function parseUnicodeExtension(chunks) {
82
- const keywords = [];
83
- let keyword;
84
- while (chunks.length && (keyword = parseKeyword(chunks))) {
85
- keywords.push(keyword);
86
- }
87
- if (keywords.length) {
88
- return {
89
- type: "u",
90
- keywords,
91
- attributes: []
92
- };
93
- }
94
- const attributes = [];
95
- while (chunks.length && ALPHANUM_3_8.test(chunks[0])) {
96
- attributes.push(chunks.shift());
97
- }
98
- while (chunks.length && (keyword = parseKeyword(chunks))) {
99
- keywords.push(keyword);
100
- }
101
- if (keywords.length || attributes.length) {
102
- return {
103
- type: "u",
104
- attributes,
105
- keywords
106
- };
107
- }
108
- throw new RangeError("Malformed unicode_extension");
109
- }
110
- function parseKeyword(chunks) {
111
- let key;
112
- if (!KEY_REGEX.test(chunks[0])) {
113
- return;
114
- }
115
- key = chunks.shift();
116
- const type = [];
117
- while (chunks.length && TYPE_REGEX.test(chunks[0])) {
118
- type.push(chunks.shift());
119
- }
120
- let value = "";
121
- if (type.length) {
122
- value = type.join(SEPARATOR);
123
- }
124
- return [key, value];
125
- }
126
- function parseTransformedExtension(chunks) {
127
- let lang;
128
- try {
129
- lang = parseUnicodeLanguageId(chunks);
130
- } catch (e) {
131
- }
132
- const fields = [];
133
- while (chunks.length && TKEY_REGEX.test(chunks[0])) {
134
- const key = chunks.shift();
135
- const value = [];
136
- while (chunks.length && ALPHANUM_3_8.test(chunks[0])) {
137
- value.push(chunks.shift());
138
- }
139
- if (!value.length) {
140
- throw new RangeError(`Missing tvalue for tkey "${key}"`);
141
- }
142
- fields.push([key, value.join(SEPARATOR)]);
143
- }
144
- if (fields.length) {
145
- return {
146
- type: "t",
147
- fields,
148
- lang
149
- };
150
- }
151
- throw new RangeError("Malformed transformed_extension");
152
- }
153
- function parsePuExtension(chunks) {
154
- const exts = [];
155
- while (chunks.length && ALPHANUM_1_8.test(chunks[0])) {
156
- exts.push(chunks.shift());
157
- }
158
- if (exts.length) {
159
- return {
160
- type: "x",
161
- value: exts.join(SEPARATOR)
162
- };
163
- }
164
- throw new RangeError("Malformed private_use_extension");
165
- }
166
- function parseOtherExtensionValue(chunks) {
167
- const exts = [];
168
- while (chunks.length && ALPHANUM_2_8.test(chunks[0])) {
169
- exts.push(chunks.shift());
170
- }
171
- if (exts.length) {
172
- return exts.join(SEPARATOR);
173
- }
174
- return "";
175
- }
176
- function parseExtensions(chunks) {
177
- if (!chunks.length) {
178
- return { extensions: [] };
179
- }
180
- const extensions = [];
181
- let unicodeExtension;
182
- let transformedExtension;
183
- let puExtension;
184
- const otherExtensionMap = {};
185
- do {
186
- const type = chunks.shift();
187
- switch (type) {
188
- case "u":
189
- case "U":
190
- if (unicodeExtension) {
191
- throw new RangeError("There can only be 1 -u- extension");
192
- }
193
- unicodeExtension = parseUnicodeExtension(chunks);
194
- extensions.push(unicodeExtension);
195
- break;
196
- case "t":
197
- case "T":
198
- if (transformedExtension) {
199
- throw new RangeError("There can only be 1 -t- extension");
200
- }
201
- transformedExtension = parseTransformedExtension(chunks);
202
- extensions.push(transformedExtension);
203
- break;
204
- case "x":
205
- case "X":
206
- if (puExtension) {
207
- throw new RangeError("There can only be 1 -x- extension");
208
- }
209
- puExtension = parsePuExtension(chunks);
210
- extensions.push(puExtension);
211
- break;
212
- default:
213
- if (!OTHER_EXTENSION_TYPE.test(type)) {
214
- throw new RangeError("Malformed extension type");
215
- }
216
- if (type in otherExtensionMap) {
217
- throw new RangeError(`There can only be 1 -${type}- extension`);
218
- }
219
- const extension = {
220
- type,
221
- value: parseOtherExtensionValue(chunks)
222
- };
223
- otherExtensionMap[extension.type] = extension;
224
- extensions.push(extension);
225
- break;
226
- }
227
- } while (chunks.length);
228
- return { extensions };
229
- }
230
- function parseUnicodeLocaleId(locale) {
231
- const chunks = locale.split(SEPARATOR);
232
- const lang = parseUnicodeLanguageId(chunks);
233
- return __spreadValues({
234
- lang
235
- }, parseExtensions(chunks));
236
- }
237
-
238
- // packages/intl-getcanonicallocales/src/emitter.ts
239
- function emitUnicodeLanguageId(lang) {
240
- if (!lang) {
241
- return "";
242
- }
243
- return [lang.lang, lang.script, lang.region, ...lang.variants || []].filter(Boolean).join("-");
244
- }
245
- function emitUnicodeLocaleId({
246
- lang,
247
- extensions
248
- }) {
249
- const chunks = [emitUnicodeLanguageId(lang)];
250
- for (const ext of extensions) {
251
- chunks.push(ext.type);
252
- switch (ext.type) {
253
- case "u":
254
- chunks.push(
255
- ...ext.attributes,
256
- ...ext.keywords.reduce((all, kv) => all.concat(kv), [])
257
- );
258
- break;
259
- case "t":
260
- chunks.push(
261
- emitUnicodeLanguageId(ext.lang),
262
- ...ext.fields.reduce((all, kv) => all.concat(kv), [])
263
- );
264
- break;
265
- default:
266
- chunks.push(ext.value);
267
- break;
268
- }
269
- }
270
- return chunks.filter(Boolean).join("-");
271
- }
272
-
273
19
  // packages/intl-getcanonicallocales/src/aliases.generated.ts
274
20
  var languageAlias = {
275
21
  "aa-saaho": "ssy",
@@ -1421,6 +1167,41 @@
1421
1167
  "polytoni": "polyton"
1422
1168
  };
1423
1169
 
1170
+ // packages/intl-getcanonicallocales/src/emitter.ts
1171
+ function emitUnicodeLanguageId(lang) {
1172
+ if (!lang) {
1173
+ return "";
1174
+ }
1175
+ return [lang.lang, lang.script, lang.region, ...lang.variants || []].filter(Boolean).join("-");
1176
+ }
1177
+ function emitUnicodeLocaleId({
1178
+ lang,
1179
+ extensions
1180
+ }) {
1181
+ const chunks = [emitUnicodeLanguageId(lang)];
1182
+ for (const ext of extensions) {
1183
+ chunks.push(ext.type);
1184
+ switch (ext.type) {
1185
+ case "u":
1186
+ chunks.push(
1187
+ ...ext.attributes,
1188
+ ...ext.keywords.reduce((all, kv) => all.concat(kv), [])
1189
+ );
1190
+ break;
1191
+ case "t":
1192
+ chunks.push(
1193
+ emitUnicodeLanguageId(ext.lang),
1194
+ ...ext.fields.reduce((all, kv) => all.concat(kv), [])
1195
+ );
1196
+ break;
1197
+ default:
1198
+ chunks.push(ext.value);
1199
+ break;
1200
+ }
1201
+ }
1202
+ return chunks.filter(Boolean).join("-");
1203
+ }
1204
+
1424
1205
  // packages/intl-getcanonicallocales/src/likelySubtags.generated.ts
1425
1206
  var likelySubtags = {
1426
1207
  "aa": "aa-Latn-ET",
@@ -9163,6 +8944,225 @@
9163
8944
  "zzj": "zzj-Hani-CN"
9164
8945
  };
9165
8946
 
8947
+ // packages/intl-getcanonicallocales/src/parser.ts
8948
+ var ALPHANUM_1_8 = /^[a-z0-9]{1,8}$/i;
8949
+ var ALPHANUM_2_8 = /^[a-z0-9]{2,8}$/i;
8950
+ var ALPHANUM_3_8 = /^[a-z0-9]{3,8}$/i;
8951
+ var KEY_REGEX = /^[a-z0-9][a-z]$/i;
8952
+ var TYPE_REGEX = /^[a-z0-9]{3,8}$/i;
8953
+ var ALPHA_4 = /^[a-z]{4}$/i;
8954
+ var OTHER_EXTENSION_TYPE = /^[0-9a-svwyz]$/i;
8955
+ var UNICODE_REGION_SUBTAG_REGEX = /^([a-z]{2}|[0-9]{3})$/i;
8956
+ var UNICODE_VARIANT_SUBTAG_REGEX = /^([a-z0-9]{5,8}|[0-9][a-z0-9]{3})$/i;
8957
+ var UNICODE_LANGUAGE_SUBTAG_REGEX = /^([a-z]{2,3}|[a-z]{5,8})$/i;
8958
+ var TKEY_REGEX = /^[a-z][0-9]$/i;
8959
+ var SEPARATOR = "-";
8960
+ function isUnicodeLanguageSubtag(lang) {
8961
+ return UNICODE_LANGUAGE_SUBTAG_REGEX.test(lang);
8962
+ }
8963
+ function isUnicodeRegionSubtag(region) {
8964
+ return UNICODE_REGION_SUBTAG_REGEX.test(region);
8965
+ }
8966
+ function isUnicodeScriptSubtag(script) {
8967
+ return ALPHA_4.test(script);
8968
+ }
8969
+ function isUnicodeVariantSubtag(variant) {
8970
+ return UNICODE_VARIANT_SUBTAG_REGEX.test(variant);
8971
+ }
8972
+ function parseUnicodeLanguageId(chunks) {
8973
+ if (typeof chunks === "string") {
8974
+ chunks = chunks.split(SEPARATOR);
8975
+ }
8976
+ const lang = chunks.shift();
8977
+ if (!lang) {
8978
+ throw new RangeError("Missing unicode_language_subtag");
8979
+ }
8980
+ if (lang === "root") {
8981
+ return { lang: "root", variants: [] };
8982
+ }
8983
+ if (!isUnicodeLanguageSubtag(lang)) {
8984
+ throw new RangeError("Malformed unicode_language_subtag");
8985
+ }
8986
+ let script;
8987
+ if (chunks.length && isUnicodeScriptSubtag(chunks[0])) {
8988
+ script = chunks.shift();
8989
+ }
8990
+ let region;
8991
+ if (chunks.length && isUnicodeRegionSubtag(chunks[0])) {
8992
+ region = chunks.shift();
8993
+ }
8994
+ const variants = {};
8995
+ while (chunks.length && isUnicodeVariantSubtag(chunks[0])) {
8996
+ const variant = chunks.shift();
8997
+ if (variant in variants) {
8998
+ throw new RangeError(`Duplicate variant "${variant}"`);
8999
+ }
9000
+ variants[variant] = 1;
9001
+ }
9002
+ return {
9003
+ lang,
9004
+ script,
9005
+ region,
9006
+ variants: Object.keys(variants)
9007
+ };
9008
+ }
9009
+ function parseUnicodeExtension(chunks) {
9010
+ const keywords = [];
9011
+ let keyword;
9012
+ while (chunks.length && (keyword = parseKeyword(chunks))) {
9013
+ keywords.push(keyword);
9014
+ }
9015
+ if (keywords.length) {
9016
+ return {
9017
+ type: "u",
9018
+ keywords,
9019
+ attributes: []
9020
+ };
9021
+ }
9022
+ const attributes = [];
9023
+ while (chunks.length && ALPHANUM_3_8.test(chunks[0])) {
9024
+ attributes.push(chunks.shift());
9025
+ }
9026
+ while (chunks.length && (keyword = parseKeyword(chunks))) {
9027
+ keywords.push(keyword);
9028
+ }
9029
+ if (keywords.length || attributes.length) {
9030
+ return {
9031
+ type: "u",
9032
+ attributes,
9033
+ keywords
9034
+ };
9035
+ }
9036
+ throw new RangeError("Malformed unicode_extension");
9037
+ }
9038
+ function parseKeyword(chunks) {
9039
+ let key;
9040
+ if (!KEY_REGEX.test(chunks[0])) {
9041
+ return;
9042
+ }
9043
+ key = chunks.shift();
9044
+ const type = [];
9045
+ while (chunks.length && TYPE_REGEX.test(chunks[0])) {
9046
+ type.push(chunks.shift());
9047
+ }
9048
+ let value = "";
9049
+ if (type.length) {
9050
+ value = type.join(SEPARATOR);
9051
+ }
9052
+ return [key, value];
9053
+ }
9054
+ function parseTransformedExtension(chunks) {
9055
+ let lang;
9056
+ try {
9057
+ lang = parseUnicodeLanguageId(chunks);
9058
+ } catch (e) {
9059
+ }
9060
+ const fields = [];
9061
+ while (chunks.length && TKEY_REGEX.test(chunks[0])) {
9062
+ const key = chunks.shift();
9063
+ const value = [];
9064
+ while (chunks.length && ALPHANUM_3_8.test(chunks[0])) {
9065
+ value.push(chunks.shift());
9066
+ }
9067
+ if (!value.length) {
9068
+ throw new RangeError(`Missing tvalue for tkey "${key}"`);
9069
+ }
9070
+ fields.push([key, value.join(SEPARATOR)]);
9071
+ }
9072
+ if (fields.length) {
9073
+ return {
9074
+ type: "t",
9075
+ fields,
9076
+ lang
9077
+ };
9078
+ }
9079
+ throw new RangeError("Malformed transformed_extension");
9080
+ }
9081
+ function parsePuExtension(chunks) {
9082
+ const exts = [];
9083
+ while (chunks.length && ALPHANUM_1_8.test(chunks[0])) {
9084
+ exts.push(chunks.shift());
9085
+ }
9086
+ if (exts.length) {
9087
+ return {
9088
+ type: "x",
9089
+ value: exts.join(SEPARATOR)
9090
+ };
9091
+ }
9092
+ throw new RangeError("Malformed private_use_extension");
9093
+ }
9094
+ function parseOtherExtensionValue(chunks) {
9095
+ const exts = [];
9096
+ while (chunks.length && ALPHANUM_2_8.test(chunks[0])) {
9097
+ exts.push(chunks.shift());
9098
+ }
9099
+ if (exts.length) {
9100
+ return exts.join(SEPARATOR);
9101
+ }
9102
+ return "";
9103
+ }
9104
+ function parseExtensions(chunks) {
9105
+ if (!chunks.length) {
9106
+ return { extensions: [] };
9107
+ }
9108
+ const extensions = [];
9109
+ let unicodeExtension;
9110
+ let transformedExtension;
9111
+ let puExtension;
9112
+ const otherExtensionMap = {};
9113
+ do {
9114
+ const type = chunks.shift();
9115
+ switch (type) {
9116
+ case "u":
9117
+ case "U":
9118
+ if (unicodeExtension) {
9119
+ throw new RangeError("There can only be 1 -u- extension");
9120
+ }
9121
+ unicodeExtension = parseUnicodeExtension(chunks);
9122
+ extensions.push(unicodeExtension);
9123
+ break;
9124
+ case "t":
9125
+ case "T":
9126
+ if (transformedExtension) {
9127
+ throw new RangeError("There can only be 1 -t- extension");
9128
+ }
9129
+ transformedExtension = parseTransformedExtension(chunks);
9130
+ extensions.push(transformedExtension);
9131
+ break;
9132
+ case "x":
9133
+ case "X":
9134
+ if (puExtension) {
9135
+ throw new RangeError("There can only be 1 -x- extension");
9136
+ }
9137
+ puExtension = parsePuExtension(chunks);
9138
+ extensions.push(puExtension);
9139
+ break;
9140
+ default:
9141
+ if (!OTHER_EXTENSION_TYPE.test(type)) {
9142
+ throw new RangeError("Malformed extension type");
9143
+ }
9144
+ if (type in otherExtensionMap) {
9145
+ throw new RangeError(`There can only be 1 -${type}- extension`);
9146
+ }
9147
+ const extension = {
9148
+ type,
9149
+ value: parseOtherExtensionValue(chunks)
9150
+ };
9151
+ otherExtensionMap[extension.type] = extension;
9152
+ extensions.push(extension);
9153
+ break;
9154
+ }
9155
+ } while (chunks.length);
9156
+ return { extensions };
9157
+ }
9158
+ function parseUnicodeLocaleId(locale) {
9159
+ const chunks = locale.split(SEPARATOR);
9160
+ const lang = parseUnicodeLanguageId(chunks);
9161
+ return __spreadValues({
9162
+ lang
9163
+ }, parseExtensions(chunks));
9164
+ }
9165
+
9166
9166
  // packages/intl-getcanonicallocales/src/canonicalizer.ts
9167
9167
  function canonicalizeAttrs(strs) {
9168
9168
  return Object.keys(
@@ -9328,7 +9328,7 @@
9328
9328
  }
9329
9329
  return finalLangAst;
9330
9330
  }
9331
- function canonicalizeUnicodeLocaleId(locale) {
9331
+ function CanonicalizeUnicodeLocaleId(locale) {
9332
9332
  locale.lang = canonicalizeUnicodeLanguageId(locale.lang);
9333
9333
  if (locale.extensions) {
9334
9334
  for (const extension of locale.extensions) {
@@ -9366,7 +9366,7 @@
9366
9366
  }
9367
9367
  for (const locale of locales) {
9368
9368
  const canonicalizedTag = emitUnicodeLocaleId(
9369
- canonicalizeUnicodeLocaleId(parseUnicodeLocaleId(locale))
9369
+ CanonicalizeUnicodeLocaleId(parseUnicodeLocaleId(locale))
9370
9370
  );
9371
9371
  if (seen.indexOf(canonicalizedTag) < 0) {
9372
9372
  seen.push(canonicalizedTag);
package/polyfill.js CHANGED
@@ -24,4 +24,3 @@ if ((0, should_polyfill_1.shouldPolyfill)()) {
24
24
  configurable: true,
25
25
  });
26
26
  }
27
- //# sourceMappingURL=polyfill.js.map
@@ -9,4 +9,3 @@ function shouldPolyfill() {
9
9
  Intl.getCanonicalLocales('und-x-private')[0] ===
10
10
  'x-private');
11
11
  }
12
- //# sourceMappingURL=should-polyfill.js.map
@@ -1152,4 +1152,3 @@ exports.variantAlias = {
1152
1152
  "heploc": "alalc97",
1153
1153
  "polytoni": "polyton"
1154
1154
  };
1155
- //# sourceMappingURL=aliases.generated.js.map
@@ -1,4 +1,4 @@
1
- import { UnicodeLocaleId, UnicodeLanguageId } from './types';
1
+ import { UnicodeLanguageId, UnicodeLocaleId } from './types';
2
2
  /**
3
3
  * CAVEAT: We don't do this section in the spec bc they have no JSON data
4
4
  * Use the bcp47 data to replace keys, types, tfields, and tvalues by their canonical forms. See Section 3.6.4 U Extension Data Files) and Section 3.7.1 T Extension Data Files. The aliases are in the alias attribute value, while the canonical is in the name attribute value. For example,
@@ -16,4 +16,4 @@ export declare function canonicalizeUnicodeLanguageId(unicodeLanguageId: Unicode
16
16
  * IMPORTANT: This modifies the object inline
17
17
  * @param locale
18
18
  */
19
- export declare function canonicalizeUnicodeLocaleId(locale: UnicodeLocaleId): UnicodeLocaleId;
19
+ export declare function CanonicalizeUnicodeLocaleId(locale: UnicodeLocaleId): UnicodeLocaleId;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.canonicalizeUnicodeLanguageId = canonicalizeUnicodeLanguageId;
4
- exports.canonicalizeUnicodeLocaleId = canonicalizeUnicodeLocaleId;
4
+ exports.CanonicalizeUnicodeLocaleId = CanonicalizeUnicodeLocaleId;
5
5
  var tslib_1 = require("tslib");
6
6
  var aliases_generated_1 = require("./aliases.generated");
7
- var parser_1 = require("./parser");
8
- var likelySubtags_generated_1 = require("./likelySubtags.generated");
9
7
  var emitter_1 = require("./emitter");
8
+ var likelySubtags_generated_1 = require("./likelySubtags.generated");
9
+ var parser_1 = require("./parser");
10
10
  function canonicalizeAttrs(strs) {
11
11
  return Object.keys(strs.reduce(function (all, str) {
12
12
  all[str.toLowerCase()] = 1;
@@ -194,7 +194,7 @@ function canonicalizeUnicodeLanguageId(unicodeLanguageId) {
194
194
  * IMPORTANT: This modifies the object inline
195
195
  * @param locale
196
196
  */
197
- function canonicalizeUnicodeLocaleId(locale) {
197
+ function CanonicalizeUnicodeLocaleId(locale) {
198
198
  locale.lang = canonicalizeUnicodeLanguageId(locale.lang);
199
199
  if (locale.extensions) {
200
200
  for (var _i = 0, _a = locale.extensions; _i < _a.length; _i++) {
@@ -221,4 +221,3 @@ function canonicalizeUnicodeLocaleId(locale) {
221
221
  }
222
222
  return locale;
223
223
  }
224
- //# sourceMappingURL=canonicalizer.js.map
package/src/emitter.js CHANGED
@@ -30,4 +30,3 @@ function emitUnicodeLocaleId(_a) {
30
30
  }
31
31
  return chunks.filter(Boolean).join('-');
32
32
  }
33
- //# sourceMappingURL=emitter.js.map
@@ -7743,4 +7743,3 @@ exports.likelySubtags = {
7743
7743
  "zza": "zza-Latn-TR",
7744
7744
  "zzj": "zzj-Hani-CN"
7745
7745
  };
7746
- //# sourceMappingURL=likelySubtags.generated.js.map
package/src/parser.js CHANGED
@@ -241,4 +241,3 @@ function parseUnicodeLocaleId(locale) {
241
241
  var lang = parseUnicodeLanguageId(chunks);
242
242
  return tslib_1.__assign({ lang: lang }, parseExtensions(chunks));
243
243
  }
244
- //# sourceMappingURL=parser.js.map
package/src/types.js CHANGED
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map