@formatjs/intl-listformat 8.1.0 → 8.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,72 +1,72 @@
1
- import { ListPatternFieldsData, ListPatternLocaleData, LiteralPart } from '@formatjs/ecma402-abstract';
1
+ import { type ListPatternFieldsData, type ListPatternLocaleData, type LiteralPart } from "@formatjs/ecma402-abstract";
2
2
  export interface IntlListFormatOptions {
3
- /**
4
- * The locale matching algorithm to use.
5
- * Possible values are "lookup" and "best fit"; the default is "best fit".
6
- * For information about this option, see
7
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation.
8
- */
9
- localeMatcher?: 'best fit' | 'lookup';
10
- /**
11
- * The format of output message.
12
- * Possible values are :
13
- * - "conjunction" that stands for "and"-based lists (default, e.g., "A, B, and C")
14
- * - "disjunction" that stands for "or"-based lists (e.g., "A, B, or C").
15
- * - "unit" stands for lists of values with units (e.g., "5 pounds, 12 ounces").
16
- */
17
- type?: 'conjunction' | 'disjunction' | 'unit';
18
- /**
19
- * The length of the formatted message.
20
- * Possible values are:
21
- * - "long" (default, e.g., "A, B, and C");
22
- * - "short" (e.g., "A, B, C"), or
23
- * - "narrow" (e.g., "A B C").
24
- * When style is "short" or "narrow", "unit" is the only allowed value for the type option.
25
- */
26
- style?: 'long' | 'short' | 'narrow';
3
+ /**
4
+ * The locale matching algorithm to use.
5
+ * Possible values are "lookup" and "best fit"; the default is "best fit".
6
+ * For information about this option, see
7
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_negotiation.
8
+ */
9
+ localeMatcher?: "best fit" | "lookup";
10
+ /**
11
+ * The format of output message.
12
+ * Possible values are :
13
+ * - "conjunction" that stands for "and"-based lists (default, e.g., "A, B, and C")
14
+ * - "disjunction" that stands for "or"-based lists (e.g., "A, B, or C").
15
+ * - "unit" stands for lists of values with units (e.g., "5 pounds, 12 ounces").
16
+ */
17
+ type?: "conjunction" | "disjunction" | "unit";
18
+ /**
19
+ * The length of the formatted message.
20
+ * Possible values are:
21
+ * - "long" (default, e.g., "A, B, and C");
22
+ * - "short" (e.g., "A, B, C"), or
23
+ * - "narrow" (e.g., "A B C").
24
+ * When style is "short" or "narrow", "unit" is the only allowed value for the type option.
25
+ */
26
+ style?: "long" | "short" | "narrow";
27
27
  }
28
28
  export interface ResolvedIntlListFormatOptions {
29
- /**
30
- * A string with a BCP 47 language tag, or an array of such strings.
31
- * For the general form and interpretation of the locales argument,
32
- * see the [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation) page.
33
- */
34
- locale: string;
35
- /**
36
- * The format of output message.
37
- * Possible values are :
38
- * - "conjunction" that stands for "and"-based lists (default, e.g., "A, B, and C")
39
- * - "disjunction" that stands for "or"-based lists (e.g., "A, B, or C").
40
- * - "unit" stands for lists of values with units (e.g., "5 pounds, 12 ounces").
41
- */
42
- type: 'conjunction' | 'disjunction' | 'unit';
43
- /**
44
- * The length of the formatted message.
45
- * Possible values are:
46
- * - "long" (default, e.g., "A, B, and C");
47
- * - "short" (e.g., "A, B, C"), or
48
- * - "narrow" (e.g., "A B C").
49
- * When style is "short" or "narrow", "unit" is the only allowed value for the type option.
50
- */
51
- style: 'long' | 'short' | 'narrow';
29
+ /**
30
+ * A string with a BCP 47 language tag, or an array of such strings.
31
+ * For the general form and interpretation of the locales argument,
32
+ * see the [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locale_identification_and_negotiation) page.
33
+ */
34
+ locale: string;
35
+ /**
36
+ * The format of output message.
37
+ * Possible values are :
38
+ * - "conjunction" that stands for "and"-based lists (default, e.g., "A, B, and C")
39
+ * - "disjunction" that stands for "or"-based lists (e.g., "A, B, or C").
40
+ * - "unit" stands for lists of values with units (e.g., "5 pounds, 12 ounces").
41
+ */
42
+ type: "conjunction" | "disjunction" | "unit";
43
+ /**
44
+ * The length of the formatted message.
45
+ * Possible values are:
46
+ * - "long" (default, e.g., "A, B, and C");
47
+ * - "short" (e.g., "A, B, C"), or
48
+ * - "narrow" (e.g., "A B C").
49
+ * When style is "short" or "narrow", "unit" is the only allowed value for the type option.
50
+ */
51
+ style: "long" | "short" | "narrow";
52
52
  }
53
53
  export type Part<T = string> = LiteralPart | ElementPart | ElementPart<T>;
54
54
  export interface ElementPart<T = string> {
55
- type: 'element';
56
- value: T;
55
+ type: "element";
56
+ value: T;
57
57
  }
58
58
  export default class ListFormat {
59
- constructor(locales?: string | string[], options?: IntlListFormatOptions);
60
- format(elements: Iterable<string>): string;
61
- formatToParts(elements: Iterable<string>): Part[];
62
- resolvedOptions(): ResolvedIntlListFormatOptions;
63
- static supportedLocalesOf(locales: string | string[], options?: Pick<IntlListFormatOptions, 'localeMatcher'>): string[];
64
- static __addLocaleData(...data: ListPatternLocaleData[]): void;
65
- static localeData: Record<string, ListPatternFieldsData | undefined>;
66
- private static availableLocales;
67
- private static __defaultLocale;
68
- private static getDefaultLocale;
69
- private static relevantExtensionKeys;
70
- static polyfilled: boolean;
71
- private static readonly __INTERNAL_SLOT_MAP__;
59
+ constructor(locales?: string | string[], options?: IntlListFormatOptions);
60
+ format(elements: Iterable<string>): string;
61
+ formatToParts(elements: Iterable<string>): Part[];
62
+ resolvedOptions(): ResolvedIntlListFormatOptions;
63
+ static supportedLocalesOf(locales: string | string[], options?: Pick<IntlListFormatOptions, "localeMatcher">): string[];
64
+ static __addLocaleData(...data: ListPatternLocaleData[]): void;
65
+ static localeData: Record<string, ListPatternFieldsData | undefined>;
66
+ private static availableLocales;
67
+ private static __defaultLocale;
68
+ private static getDefaultLocale;
69
+ private static relevantExtensionKeys;
70
+ static polyfilled: boolean;
71
+ private static readonly __INTERNAL_SLOT_MAP__;
72
72
  }
package/index.js CHANGED
@@ -1,216 +1,217 @@
1
- import { __assign } from "tslib";
2
- import { CanonicalizeLocaleList, getInternalSlot, GetOption, GetOptionsObject, invariant, isLiteralPart, PartitionPattern, setInternalSlot, SupportedLocales, } from '@formatjs/ecma402-abstract';
3
- import { ResolveLocale } from '@formatjs/intl-localematcher';
1
+ import { CanonicalizeLocaleList, getInternalSlot, GetOption, GetOptionsObject, invariant, isLiteralPart, PartitionPattern, setInternalSlot, SupportedLocales } from "@formatjs/ecma402-abstract";
2
+ import { ResolveLocale } from "@formatjs/intl-localematcher";
4
3
  function validateInstance(instance, method) {
5
- if (!(instance instanceof ListFormat)) {
6
- throw new TypeError("Method Intl.ListFormat.prototype.".concat(method, " called on incompatible receiver ").concat(String(instance)));
7
- }
4
+ if (!(instance instanceof ListFormat)) {
5
+ throw new TypeError(`Method Intl.ListFormat.prototype.${method} called on incompatible receiver ${String(instance)}`);
6
+ }
8
7
  }
9
8
  /**
10
- * https://tc39.es/proposal-intl-list-format/#sec-createstringlistfromiterable
11
- * @param iterable list
12
- */
9
+ * https://tc39.es/proposal-intl-list-format/#sec-createstringlistfromiterable
10
+ * @param iterable list
11
+ */
13
12
  function stringListFromIterable(iterable) {
14
- if (typeof iterable !== 'object')
15
- return [];
16
- var elements = [];
17
- var iterator = iterable[Symbol.iterator]();
18
- var result;
19
- while (true) {
20
- result = iterator.next();
21
- if (result.done)
22
- break;
23
- if (typeof result.value !== 'string') {
24
- var nextValue = result.value;
25
- throw new TypeError("Iterable yielded ".concat(nextValue, " which is not a string"));
26
- }
27
- elements.push(result.value);
28
- }
29
- return elements;
13
+ if (typeof iterable !== "object") return [];
14
+ const elements = [];
15
+ const iterator = iterable[Symbol.iterator]();
16
+ let result;
17
+ while (true) {
18
+ result = iterator.next();
19
+ if (result.done) break;
20
+ if (typeof result.value !== "string") {
21
+ const nextValue = result.value;
22
+ throw new TypeError(`Iterable yielded ${nextValue} which is not a string`);
23
+ }
24
+ elements.push(result.value);
25
+ }
26
+ return elements;
30
27
  }
31
28
  function createPartsFromList(internalSlotMap, lf, list) {
32
- var size = list.length;
33
- if (size === 0) {
34
- return [];
35
- }
36
- if (size === 2) {
37
- var pattern = getInternalSlot(internalSlotMap, lf, 'templatePair');
38
- var first = { type: 'element', value: list[0] };
39
- var second = { type: 'element', value: list[1] };
40
- return deconstructPattern(pattern, { '0': first, '1': second });
41
- }
42
- var last = {
43
- type: 'element',
44
- value: list[size - 1],
45
- };
46
- var parts = last;
47
- var i = size - 2;
48
- while (i >= 0) {
49
- var pattern = void 0;
50
- if (i === 0) {
51
- pattern = getInternalSlot(internalSlotMap, lf, 'templateStart');
52
- }
53
- else if (i < size - 2) {
54
- pattern = getInternalSlot(internalSlotMap, lf, 'templateMiddle');
55
- }
56
- else {
57
- pattern = getInternalSlot(internalSlotMap, lf, 'templateEnd');
58
- }
59
- var head = { type: 'element', value: list[i] };
60
- parts = deconstructPattern(pattern, { '0': head, '1': parts });
61
- i--;
62
- }
63
- return parts;
29
+ const size = list.length;
30
+ if (size === 0) {
31
+ return [];
32
+ }
33
+ if (size === 2) {
34
+ const pattern = getInternalSlot(internalSlotMap, lf, "templatePair");
35
+ const first = {
36
+ type: "element",
37
+ value: list[0]
38
+ };
39
+ const second = {
40
+ type: "element",
41
+ value: list[1]
42
+ };
43
+ return deconstructPattern(pattern, {
44
+ "0": first,
45
+ "1": second
46
+ });
47
+ }
48
+ const last = {
49
+ type: "element",
50
+ value: list[size - 1]
51
+ };
52
+ let parts = last;
53
+ let i = size - 2;
54
+ while (i >= 0) {
55
+ let pattern;
56
+ if (i === 0) {
57
+ pattern = getInternalSlot(internalSlotMap, lf, "templateStart");
58
+ } else if (i < size - 2) {
59
+ pattern = getInternalSlot(internalSlotMap, lf, "templateMiddle");
60
+ } else {
61
+ pattern = getInternalSlot(internalSlotMap, lf, "templateEnd");
62
+ }
63
+ const head = {
64
+ type: "element",
65
+ value: list[i]
66
+ };
67
+ parts = deconstructPattern(pattern, {
68
+ "0": head,
69
+ "1": parts
70
+ });
71
+ i--;
72
+ }
73
+ return parts;
64
74
  }
65
75
  function deconstructPattern(pattern, placeables) {
66
- var patternParts = PartitionPattern(pattern);
67
- var result = [];
68
- for (var _i = 0, patternParts_1 = patternParts; _i < patternParts_1.length; _i++) {
69
- var patternPart = patternParts_1[_i];
70
- var part = patternPart.type;
71
- if (isLiteralPart(patternPart)) {
72
- result.push({
73
- type: 'literal',
74
- value: patternPart.value,
75
- });
76
- }
77
- else {
78
- invariant(part in placeables, "".concat(part, " is missing from placables"));
79
- var subst = placeables[part];
80
- if (Array.isArray(subst)) {
81
- result.push.apply(result, subst);
82
- }
83
- else {
84
- result.push(subst);
85
- }
86
- }
87
- }
88
- return result;
76
+ const patternParts = PartitionPattern(pattern);
77
+ const result = [];
78
+ for (const patternPart of patternParts) {
79
+ const { type: part } = patternPart;
80
+ if (isLiteralPart(patternPart)) {
81
+ result.push({
82
+ type: "literal",
83
+ value: patternPart.value
84
+ });
85
+ } else {
86
+ invariant(part in placeables, `${part} is missing from placables`);
87
+ const subst = placeables[part];
88
+ if (Array.isArray(subst)) {
89
+ result.push(...subst);
90
+ } else {
91
+ result.push(subst);
92
+ }
93
+ }
94
+ }
95
+ return result;
89
96
  }
90
- var ListFormat = /** @class */ (function () {
91
- function ListFormat(locales, options) {
92
- // test262/test/intl402/ListFormat/constructor/constructor/newtarget-undefined.js
93
- // Cannot use `new.target` bc of IE11 & TS transpiles it to something else
94
- var newTarget = this && this instanceof ListFormat ? this.constructor : void 0;
95
- if (!newTarget) {
96
- throw new TypeError("Intl.ListFormat must be called with 'new'");
97
- }
98
- setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'initializedListFormat', true);
99
- var requestedLocales = CanonicalizeLocaleList(locales);
100
- var opt = Object.create(null);
101
- var opts = GetOptionsObject(options);
102
- var matcher = GetOption(opts, 'localeMatcher', 'string', ['best fit', 'lookup'], 'best fit');
103
- opt.localeMatcher = matcher;
104
- var localeData = ListFormat.localeData;
105
- var r = ResolveLocale(ListFormat.availableLocales, requestedLocales, opt, ListFormat.relevantExtensionKeys, localeData, ListFormat.getDefaultLocale);
106
- setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'locale', r.locale);
107
- var type = GetOption(opts, 'type', 'string', ['conjunction', 'disjunction', 'unit'], 'conjunction');
108
- setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'type', type);
109
- var style = GetOption(opts, 'style', 'string', ['long', 'short', 'narrow'], 'long');
110
- setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'style', style);
111
- var dataLocale = r.dataLocale;
112
- var dataLocaleData = localeData[dataLocale];
113
- invariant(!!dataLocaleData, "Missing locale data for ".concat(dataLocale));
114
- var dataLocaleTypes = dataLocaleData[type];
115
- var templates = dataLocaleTypes[style];
116
- setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'templatePair', templates.pair);
117
- setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'templateStart', templates.start);
118
- setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'templateMiddle', templates.middle);
119
- setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'templateEnd', templates.end);
120
- }
121
- ListFormat.prototype.format = function (elements) {
122
- validateInstance(this, 'format');
123
- var result = '';
124
- var parts = createPartsFromList(ListFormat.__INTERNAL_SLOT_MAP__, this, stringListFromIterable(elements));
125
- if (!Array.isArray(parts)) {
126
- return parts.value;
127
- }
128
- for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) {
129
- var p = parts_1[_i];
130
- result += p.value;
131
- }
132
- return result;
133
- };
134
- ListFormat.prototype.formatToParts = function (elements) {
135
- validateInstance(this, 'format');
136
- var parts = createPartsFromList(ListFormat.__INTERNAL_SLOT_MAP__, this, stringListFromIterable(elements));
137
- if (!Array.isArray(parts)) {
138
- return [parts];
139
- }
140
- var result = [];
141
- for (var _i = 0, parts_2 = parts; _i < parts_2.length; _i++) {
142
- var part = parts_2[_i];
143
- result.push(__assign({}, part));
144
- }
145
- return result;
146
- };
147
- ListFormat.prototype.resolvedOptions = function () {
148
- validateInstance(this, 'resolvedOptions');
149
- return {
150
- locale: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'locale'),
151
- type: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'type'),
152
- style: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, 'style'),
153
- };
154
- };
155
- ListFormat.supportedLocalesOf = function (locales, options) {
156
- // test262/test/intl402/ListFormat/constructor/supportedLocalesOf/result-type.js
157
- return SupportedLocales(ListFormat.availableLocales, CanonicalizeLocaleList(locales), options);
158
- };
159
- ListFormat.__addLocaleData = function () {
160
- var data = [];
161
- for (var _i = 0; _i < arguments.length; _i++) {
162
- data[_i] = arguments[_i];
163
- }
164
- for (var _a = 0, data_1 = data; _a < data_1.length; _a++) {
165
- var _b = data_1[_a], d = _b.data, locale = _b.locale;
166
- var minimizedLocale = new Intl.Locale(locale)
167
- .minimize()
168
- .toString();
169
- ListFormat.localeData[locale] = ListFormat.localeData[minimizedLocale] = d;
170
- ListFormat.availableLocales.add(minimizedLocale);
171
- ListFormat.availableLocales.add(locale);
172
- if (!ListFormat.__defaultLocale) {
173
- ListFormat.__defaultLocale = minimizedLocale;
174
- }
175
- }
176
- };
177
- ListFormat.getDefaultLocale = function () {
178
- return ListFormat.__defaultLocale;
179
- };
180
- ListFormat.localeData = {};
181
- ListFormat.availableLocales = new Set();
182
- ListFormat.__defaultLocale = '';
183
- ListFormat.relevantExtensionKeys = [];
184
- ListFormat.polyfilled = true;
185
- ListFormat.__INTERNAL_SLOT_MAP__ = new WeakMap();
186
- return ListFormat;
187
- }());
188
- export default ListFormat;
189
- try {
190
- // IE11 does not have Symbol
191
- if (typeof Symbol !== 'undefined') {
192
- Object.defineProperty(ListFormat.prototype, Symbol.toStringTag, {
193
- value: 'Intl.ListFormat',
194
- writable: false,
195
- enumerable: false,
196
- configurable: true,
197
- });
198
- }
199
- // https://github.com/tc39/test262/blob/master/test/intl402/ListFormat/constructor/length.js
200
- Object.defineProperty(ListFormat.prototype.constructor, 'length', {
201
- value: 0,
202
- writable: false,
203
- enumerable: false,
204
- configurable: true,
205
- });
206
- // https://github.com/tc39/test262/blob/master/test/intl402/ListFormat/constructor/supportedLocalesOf/length.js
207
- Object.defineProperty(ListFormat.supportedLocalesOf, 'length', {
208
- value: 1,
209
- writable: false,
210
- enumerable: false,
211
- configurable: true,
212
- });
213
- }
214
- catch (_a) {
215
- // Meta fix so we're test262-compliant, not important
97
+ export default class ListFormat {
98
+ constructor(locales, options) {
99
+ // test262/test/intl402/ListFormat/constructor/constructor/newtarget-undefined.js
100
+ // Cannot use `new.target` bc of IE11 & TS transpiles it to something else
101
+ const newTarget = this && this instanceof ListFormat ? this.constructor : void 0;
102
+ if (!newTarget) {
103
+ throw new TypeError("Intl.ListFormat must be called with 'new'");
104
+ }
105
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "initializedListFormat", true);
106
+ const requestedLocales = CanonicalizeLocaleList(locales);
107
+ const opt = Object.create(null);
108
+ const opts = GetOptionsObject(options);
109
+ const matcher = GetOption(opts, "localeMatcher", "string", ["best fit", "lookup"], "best fit");
110
+ opt.localeMatcher = matcher;
111
+ const { localeData } = ListFormat;
112
+ const r = ResolveLocale(ListFormat.availableLocales, requestedLocales, opt, ListFormat.relevantExtensionKeys, localeData, ListFormat.getDefaultLocale);
113
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "locale", r.locale);
114
+ const type = GetOption(opts, "type", "string", [
115
+ "conjunction",
116
+ "disjunction",
117
+ "unit"
118
+ ], "conjunction");
119
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "type", type);
120
+ const style = GetOption(opts, "style", "string", [
121
+ "long",
122
+ "short",
123
+ "narrow"
124
+ ], "long");
125
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "style", style);
126
+ const { dataLocale } = r;
127
+ const dataLocaleData = localeData[dataLocale];
128
+ invariant(!!dataLocaleData, `Missing locale data for ${dataLocale}`);
129
+ const dataLocaleTypes = dataLocaleData[type];
130
+ const templates = dataLocaleTypes[style];
131
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "templatePair", templates.pair);
132
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "templateStart", templates.start);
133
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "templateMiddle", templates.middle);
134
+ setInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "templateEnd", templates.end);
135
+ }
136
+ format(elements) {
137
+ validateInstance(this, "format");
138
+ let result = "";
139
+ const parts = createPartsFromList(ListFormat.__INTERNAL_SLOT_MAP__, this, stringListFromIterable(elements));
140
+ if (!Array.isArray(parts)) {
141
+ return parts.value;
142
+ }
143
+ for (const p of parts) {
144
+ result += p.value;
145
+ }
146
+ return result;
147
+ }
148
+ formatToParts(elements) {
149
+ validateInstance(this, "format");
150
+ const parts = createPartsFromList(ListFormat.__INTERNAL_SLOT_MAP__, this, stringListFromIterable(elements));
151
+ if (!Array.isArray(parts)) {
152
+ return [parts];
153
+ }
154
+ const result = [];
155
+ for (const part of parts) {
156
+ result.push({ ...part });
157
+ }
158
+ return result;
159
+ }
160
+ resolvedOptions() {
161
+ validateInstance(this, "resolvedOptions");
162
+ return {
163
+ locale: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "locale"),
164
+ type: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "type"),
165
+ style: getInternalSlot(ListFormat.__INTERNAL_SLOT_MAP__, this, "style")
166
+ };
167
+ }
168
+ static supportedLocalesOf(locales, options) {
169
+ // test262/test/intl402/ListFormat/constructor/supportedLocalesOf/result-type.js
170
+ return SupportedLocales(ListFormat.availableLocales, CanonicalizeLocaleList(locales), options);
171
+ }
172
+ static __addLocaleData(...data) {
173
+ for (const { data: d, locale } of data) {
174
+ const minimizedLocale = new Intl.Locale(locale).minimize().toString();
175
+ ListFormat.localeData[locale] = ListFormat.localeData[minimizedLocale] = d;
176
+ ListFormat.availableLocales.add(minimizedLocale);
177
+ ListFormat.availableLocales.add(locale);
178
+ if (!ListFormat.__defaultLocale) {
179
+ ListFormat.__defaultLocale = minimizedLocale;
180
+ }
181
+ }
182
+ }
183
+ static localeData = {};
184
+ static availableLocales = new Set();
185
+ static __defaultLocale = "";
186
+ static getDefaultLocale() {
187
+ return ListFormat.__defaultLocale;
188
+ }
189
+ static relevantExtensionKeys = [];
190
+ static polyfilled = true;
191
+ static __INTERNAL_SLOT_MAP__ = new WeakMap();
216
192
  }
193
+ try {
194
+ // IE11 does not have Symbol
195
+ if (typeof Symbol !== "undefined") {
196
+ Object.defineProperty(ListFormat.prototype, Symbol.toStringTag, {
197
+ value: "Intl.ListFormat",
198
+ writable: false,
199
+ enumerable: false,
200
+ configurable: true
201
+ });
202
+ }
203
+ // https://github.com/tc39/test262/blob/master/test/intl402/ListFormat/constructor/length.js
204
+ Object.defineProperty(ListFormat.prototype.constructor, "length", {
205
+ value: 0,
206
+ writable: false,
207
+ enumerable: false,
208
+ configurable: true
209
+ });
210
+ // https://github.com/tc39/test262/blob/master/test/intl402/ListFormat/constructor/supportedLocalesOf/length.js
211
+ Object.defineProperty(ListFormat.supportedLocalesOf, "length", {
212
+ value: 1,
213
+ writable: false,
214
+ enumerable: false,
215
+ configurable: true
216
+ });
217
+ } catch {}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@formatjs/intl-listformat",
3
3
  "description": "Formats JS list in a i18n-safe way",
4
- "version": "8.1.0",
4
+ "version": "8.1.2",
5
5
  "license": "MIT",
6
6
  "author": "Long Ho <holevietlong@gmail.com>",
7
7
  "type": "module",
@@ -15,12 +15,12 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "tslib": "^2.8.0",
18
- "@formatjs/ecma402-abstract": "3.0.6",
19
- "@formatjs/intl-localematcher": "0.7.3"
18
+ "@formatjs/intl-localematcher": "0.7.5",
19
+ "@formatjs/ecma402-abstract": "3.0.8"
20
20
  },
21
21
  "devDependencies": {
22
- "@formatjs/intl-getcanonicallocales": "3.1.0",
23
- "@formatjs/intl-locale": "5.1.0"
22
+ "@formatjs/intl-getcanonicallocales": "3.1.2",
23
+ "@formatjs/intl-locale": "5.1.2"
24
24
  },
25
25
  "bugs": "https://github.com/formatjs/formatjs/issues",
26
26
  "gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c",
package/polyfill-force.js CHANGED
@@ -1,7 +1,7 @@
1
- import ListFormat from './index.js';
2
- Object.defineProperty(Intl, 'ListFormat', {
3
- value: ListFormat,
4
- writable: true,
5
- enumerable: false,
6
- configurable: true,
1
+ import ListFormat from "./index.js";
2
+ Object.defineProperty(Intl, "ListFormat", {
3
+ value: ListFormat,
4
+ writable: true,
5
+ enumerable: false,
6
+ configurable: true
7
7
  });