@formatjs/intl-supportedvaluesof 2.1.2 → 2.2.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.
- package/index.d.ts +8 -0
- package/index.js +2 -0
- package/package.json +5 -5
- package/polyfill-force.d.ts +1 -0
- package/polyfill-force.js +7 -0
- package/polyfill.d.ts +1 -0
- package/polyfill.iife.js +6105 -0
- package/polyfill.js +10 -0
- package/should-polyfill.d.ts +1 -0
- package/should-polyfill.js +3 -0
- package/src/calendars.generated.d.ts +2 -0
- package/src/calendars.generated.js +23 -0
- package/src/collations.generated.d.ts +2 -0
- package/src/collations.generated.js +23 -0
- package/src/currencies.generated.d.ts +2 -0
- package/src/currencies.generated.js +311 -0
- package/src/get-supported-calendars.d.ts +8 -0
- package/src/get-supported-calendars.js +27 -0
- package/src/get-supported-collations.d.ts +8 -0
- package/src/get-supported-collations.js +23 -0
- package/src/get-supported-currencies.d.ts +8 -0
- package/src/get-supported-currencies.js +50 -0
- package/src/get-supported-numbering-systems.d.ts +7 -0
- package/src/get-supported-numbering-systems.js +28 -0
- package/src/get-supported-timezones.d.ts +8 -0
- package/src/get-supported-timezones.js +25 -0
- package/src/get-supported-units.d.ts +7 -0
- package/src/get-supported-units.js +28 -0
- package/src/index.d.ts +33 -0
- package/src/index.js +34 -0
- package/src/memoize.d.ts +9 -0
- package/src/memoize.js +10 -0
- package/src/numbering-systems.generated.d.ts +1 -0
- package/src/numbering-systems.generated.js +99 -0
- package/src/timezones.generated.d.ts +2 -0
- package/src/timezones.generated.js +431 -0
- package/src/units.generated.d.ts +2 -0
- package/src/units.generated.js +47 -0
- package/BUILD.bazel +0 -135
- package/CHANGELOG.md +0 -249
- package/index.ts +0 -9
- package/polyfill-force.ts +0 -8
- package/polyfill.ts +0 -11
- package/scripts/calendars.ts +0 -21
- package/scripts/collations.ts +0 -21
- package/scripts/currencies.ts +0 -21
- package/scripts/timezones.ts +0 -22
- package/scripts/units.ts +0 -23
- package/should-polyfill.ts +0 -3
- package/src/calendars.generated.ts +0 -4
- package/src/collations.generated.ts +0 -4
- package/src/currencies.generated.ts +0 -4
- package/src/get-supported-calendars.ts +0 -32
- package/src/get-supported-collations.ts +0 -30
- package/src/get-supported-currencies.ts +0 -62
- package/src/get-supported-numbering-systems.ts +0 -35
- package/src/get-supported-timezones.ts +0 -29
- package/src/get-supported-units.ts +0 -73
- package/src/index.ts +0 -75
- package/src/memoize.ts +0 -19
- package/src/numbering-systems.generated.ts +0 -99
- package/src/timezones.generated.ts +0 -4
- package/src/units.generated.ts +0 -4
- package/tests/index.test.ts +0 -155
- package/tsconfig.json +0 -5
package/polyfill.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { shouldPolyfill } from "./should-polyfill.js";
|
|
2
|
+
import { supportedValuesOf } from "./src";
|
|
3
|
+
if (shouldPolyfill()) {
|
|
4
|
+
Object.defineProperty(Intl, "supportedValuesOf", {
|
|
5
|
+
value: supportedValuesOf,
|
|
6
|
+
enumerable: true,
|
|
7
|
+
writable: false,
|
|
8
|
+
configurable: false
|
|
9
|
+
});
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function shouldPolyfill(): boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const calendars: readonly ["buddhist", "chinese", "coptic", "dangi", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamic-civil", "islamic-rgsa", "islamic-tbla", "islamic-umalqura", "islamicc", "iso8601", "japanese", "persian", "roc"];
|
|
2
|
+
export type Calendar = (typeof calendars)[number];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* @generated */
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
export const calendars = [
|
|
4
|
+
"buddhist",
|
|
5
|
+
"chinese",
|
|
6
|
+
"coptic",
|
|
7
|
+
"dangi",
|
|
8
|
+
"ethioaa",
|
|
9
|
+
"ethiopic",
|
|
10
|
+
"gregory",
|
|
11
|
+
"hebrew",
|
|
12
|
+
"indian",
|
|
13
|
+
"islamic",
|
|
14
|
+
"islamic-civil",
|
|
15
|
+
"islamic-rgsa",
|
|
16
|
+
"islamic-tbla",
|
|
17
|
+
"islamic-umalqura",
|
|
18
|
+
"islamicc",
|
|
19
|
+
"iso8601",
|
|
20
|
+
"japanese",
|
|
21
|
+
"persian",
|
|
22
|
+
"roc"
|
|
23
|
+
];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const collations: readonly ["big5han", "compat", "dict", "direct", "ducet", "emoji", "eor", "gb2312", "phonebk", "phonetic", "pinyin", "reformed", "search", "searchjl", "standard", "stroke", "trad", "unihan", "zhuyin"];
|
|
2
|
+
export type Collation = (typeof collations)[number];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* @generated */
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
export const collations = [
|
|
4
|
+
"big5han",
|
|
5
|
+
"compat",
|
|
6
|
+
"dict",
|
|
7
|
+
"direct",
|
|
8
|
+
"ducet",
|
|
9
|
+
"emoji",
|
|
10
|
+
"eor",
|
|
11
|
+
"gb2312",
|
|
12
|
+
"phonebk",
|
|
13
|
+
"phonetic",
|
|
14
|
+
"pinyin",
|
|
15
|
+
"reformed",
|
|
16
|
+
"search",
|
|
17
|
+
"searchjl",
|
|
18
|
+
"standard",
|
|
19
|
+
"stroke",
|
|
20
|
+
"trad",
|
|
21
|
+
"unihan",
|
|
22
|
+
"zhuyin"
|
|
23
|
+
];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const currencies: readonly ["ADP", "AED", "AFA", "AFN", "ALK", "ALL", "AMD", "ANG", "AOA", "AOK", "AON", "AOR", "ARA", "ARL", "ARM", "ARP", "ARS", "ATS", "AUD", "AWG", "AZM", "AZN", "BAD", "BAM", "BAN", "BBD", "BDT", "BEC", "BEF", "BEL", "BGL", "BGM", "BGN", "BGO", "BHD", "BIF", "BMD", "BND", "BOB", "BOL", "BOP", "BOV", "BRB", "BRC", "BRE", "BRL", "BRN", "BRR", "BRZ", "BSD", "BTN", "BUK", "BWP", "BYB", "BYN", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLE", "CLF", "CLP", "CNH", "CNX", "CNY", "COP", "COU", "CRC", "CSD", "CSK", "CUC", "CUP", "CVE", "CYP", "CZK", "DDM", "DEM", "DJF", "DKK", "DOP", "DZD", "ECS", "ECV", "EEK", "EGP", "ERN", "ESA", "ESB", "ESP", "ETB", "EUR", "FIM", "FJD", "FKP", "FRF", "GBP", "GEK", "GEL", "GHC", "GHS", "GIP", "GMD", "GNF", "GNS", "GQE", "GRD", "GTQ", "GWE", "GWP", "GYD", "HKD", "HNL", "HRD", "HRK", "HTG", "HUF", "IDR", "IEP", "ILP", "ILR", "ILS", "INR", "IQD", "IRR", "ISJ", "ISK", "ITL", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRH", "KRO", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LTT", "LUC", "LUF", "LUL", "LVL", "LVR", "LYD", "MAD", "MAF", "MCF", "MDC", "MDL", "MGA", "MGF", "MKD", "MKN", "MLF", "MMK", "MNT", "MOP", "MRO", "MRU", "MTL", "MTP", "MUR", "MVP", "MVR", "MWK", "MXN", "MXP", "MXV", "MYR", "MZE", "MZM", "MZN", "NAD", "NGN", "NIC", "NIO", "NLG", "NOK", "NPR", "NZD", "OMR", "PAB", "PEI", "PEN", "PES", "PGK", "PHP", "PKR", "PLN", "PLZ", "PTE", "PYG", "QAR", "RHD", "ROL", "RON", "RSD", "RUB", "RUR", "RWF", "SAR", "SBD", "SCR", "SDD", "SDG", "SDP", "SEK", "SGD", "SHP", "SIT", "SKK", "SLE", "SLL", "SOS", "SRD", "SRG", "SSP", "STD", "STN", "SUR", "SVC", "SYP", "SZL", "THB", "TJR", "TJS", "TMM", "TMT", "TND", "TOP", "TPE", "TRL", "TRY", "TTD", "TWD", "TZS", "UAH", "UAK", "UGS", "UGX", "USD", "USN", "USS", "UYI", "UYP", "UYU", "UYW", "UZS", "VEB", "VED", "VEF", "VES", "VND", "VNN", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XCG", "XDR", "XEU", "XFO", "XFU", "XOF", "XPD", "XPF", "XPT", "XRE", "XSU", "XTS", "XUA", "XXX", "YDD", "YER", "YUD", "YUM", "YUN", "YUR", "ZAL", "ZAR", "ZMK", "ZMW", "ZRN", "ZRZ", "ZWD", "ZWG", "ZWL", "ZWR"];
|
|
2
|
+
export type Currency = (typeof currencies)[number];
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/* @generated */
|
|
2
|
+
// prettier-ignore
|
|
3
|
+
export const currencies = [
|
|
4
|
+
"ADP",
|
|
5
|
+
"AED",
|
|
6
|
+
"AFA",
|
|
7
|
+
"AFN",
|
|
8
|
+
"ALK",
|
|
9
|
+
"ALL",
|
|
10
|
+
"AMD",
|
|
11
|
+
"ANG",
|
|
12
|
+
"AOA",
|
|
13
|
+
"AOK",
|
|
14
|
+
"AON",
|
|
15
|
+
"AOR",
|
|
16
|
+
"ARA",
|
|
17
|
+
"ARL",
|
|
18
|
+
"ARM",
|
|
19
|
+
"ARP",
|
|
20
|
+
"ARS",
|
|
21
|
+
"ATS",
|
|
22
|
+
"AUD",
|
|
23
|
+
"AWG",
|
|
24
|
+
"AZM",
|
|
25
|
+
"AZN",
|
|
26
|
+
"BAD",
|
|
27
|
+
"BAM",
|
|
28
|
+
"BAN",
|
|
29
|
+
"BBD",
|
|
30
|
+
"BDT",
|
|
31
|
+
"BEC",
|
|
32
|
+
"BEF",
|
|
33
|
+
"BEL",
|
|
34
|
+
"BGL",
|
|
35
|
+
"BGM",
|
|
36
|
+
"BGN",
|
|
37
|
+
"BGO",
|
|
38
|
+
"BHD",
|
|
39
|
+
"BIF",
|
|
40
|
+
"BMD",
|
|
41
|
+
"BND",
|
|
42
|
+
"BOB",
|
|
43
|
+
"BOL",
|
|
44
|
+
"BOP",
|
|
45
|
+
"BOV",
|
|
46
|
+
"BRB",
|
|
47
|
+
"BRC",
|
|
48
|
+
"BRE",
|
|
49
|
+
"BRL",
|
|
50
|
+
"BRN",
|
|
51
|
+
"BRR",
|
|
52
|
+
"BRZ",
|
|
53
|
+
"BSD",
|
|
54
|
+
"BTN",
|
|
55
|
+
"BUK",
|
|
56
|
+
"BWP",
|
|
57
|
+
"BYB",
|
|
58
|
+
"BYN",
|
|
59
|
+
"BYR",
|
|
60
|
+
"BZD",
|
|
61
|
+
"CAD",
|
|
62
|
+
"CDF",
|
|
63
|
+
"CHE",
|
|
64
|
+
"CHF",
|
|
65
|
+
"CHW",
|
|
66
|
+
"CLE",
|
|
67
|
+
"CLF",
|
|
68
|
+
"CLP",
|
|
69
|
+
"CNH",
|
|
70
|
+
"CNX",
|
|
71
|
+
"CNY",
|
|
72
|
+
"COP",
|
|
73
|
+
"COU",
|
|
74
|
+
"CRC",
|
|
75
|
+
"CSD",
|
|
76
|
+
"CSK",
|
|
77
|
+
"CUC",
|
|
78
|
+
"CUP",
|
|
79
|
+
"CVE",
|
|
80
|
+
"CYP",
|
|
81
|
+
"CZK",
|
|
82
|
+
"DDM",
|
|
83
|
+
"DEM",
|
|
84
|
+
"DJF",
|
|
85
|
+
"DKK",
|
|
86
|
+
"DOP",
|
|
87
|
+
"DZD",
|
|
88
|
+
"ECS",
|
|
89
|
+
"ECV",
|
|
90
|
+
"EEK",
|
|
91
|
+
"EGP",
|
|
92
|
+
"ERN",
|
|
93
|
+
"ESA",
|
|
94
|
+
"ESB",
|
|
95
|
+
"ESP",
|
|
96
|
+
"ETB",
|
|
97
|
+
"EUR",
|
|
98
|
+
"FIM",
|
|
99
|
+
"FJD",
|
|
100
|
+
"FKP",
|
|
101
|
+
"FRF",
|
|
102
|
+
"GBP",
|
|
103
|
+
"GEK",
|
|
104
|
+
"GEL",
|
|
105
|
+
"GHC",
|
|
106
|
+
"GHS",
|
|
107
|
+
"GIP",
|
|
108
|
+
"GMD",
|
|
109
|
+
"GNF",
|
|
110
|
+
"GNS",
|
|
111
|
+
"GQE",
|
|
112
|
+
"GRD",
|
|
113
|
+
"GTQ",
|
|
114
|
+
"GWE",
|
|
115
|
+
"GWP",
|
|
116
|
+
"GYD",
|
|
117
|
+
"HKD",
|
|
118
|
+
"HNL",
|
|
119
|
+
"HRD",
|
|
120
|
+
"HRK",
|
|
121
|
+
"HTG",
|
|
122
|
+
"HUF",
|
|
123
|
+
"IDR",
|
|
124
|
+
"IEP",
|
|
125
|
+
"ILP",
|
|
126
|
+
"ILR",
|
|
127
|
+
"ILS",
|
|
128
|
+
"INR",
|
|
129
|
+
"IQD",
|
|
130
|
+
"IRR",
|
|
131
|
+
"ISJ",
|
|
132
|
+
"ISK",
|
|
133
|
+
"ITL",
|
|
134
|
+
"JMD",
|
|
135
|
+
"JOD",
|
|
136
|
+
"JPY",
|
|
137
|
+
"KES",
|
|
138
|
+
"KGS",
|
|
139
|
+
"KHR",
|
|
140
|
+
"KMF",
|
|
141
|
+
"KPW",
|
|
142
|
+
"KRH",
|
|
143
|
+
"KRO",
|
|
144
|
+
"KRW",
|
|
145
|
+
"KWD",
|
|
146
|
+
"KYD",
|
|
147
|
+
"KZT",
|
|
148
|
+
"LAK",
|
|
149
|
+
"LBP",
|
|
150
|
+
"LKR",
|
|
151
|
+
"LRD",
|
|
152
|
+
"LSL",
|
|
153
|
+
"LTL",
|
|
154
|
+
"LTT",
|
|
155
|
+
"LUC",
|
|
156
|
+
"LUF",
|
|
157
|
+
"LUL",
|
|
158
|
+
"LVL",
|
|
159
|
+
"LVR",
|
|
160
|
+
"LYD",
|
|
161
|
+
"MAD",
|
|
162
|
+
"MAF",
|
|
163
|
+
"MCF",
|
|
164
|
+
"MDC",
|
|
165
|
+
"MDL",
|
|
166
|
+
"MGA",
|
|
167
|
+
"MGF",
|
|
168
|
+
"MKD",
|
|
169
|
+
"MKN",
|
|
170
|
+
"MLF",
|
|
171
|
+
"MMK",
|
|
172
|
+
"MNT",
|
|
173
|
+
"MOP",
|
|
174
|
+
"MRO",
|
|
175
|
+
"MRU",
|
|
176
|
+
"MTL",
|
|
177
|
+
"MTP",
|
|
178
|
+
"MUR",
|
|
179
|
+
"MVP",
|
|
180
|
+
"MVR",
|
|
181
|
+
"MWK",
|
|
182
|
+
"MXN",
|
|
183
|
+
"MXP",
|
|
184
|
+
"MXV",
|
|
185
|
+
"MYR",
|
|
186
|
+
"MZE",
|
|
187
|
+
"MZM",
|
|
188
|
+
"MZN",
|
|
189
|
+
"NAD",
|
|
190
|
+
"NGN",
|
|
191
|
+
"NIC",
|
|
192
|
+
"NIO",
|
|
193
|
+
"NLG",
|
|
194
|
+
"NOK",
|
|
195
|
+
"NPR",
|
|
196
|
+
"NZD",
|
|
197
|
+
"OMR",
|
|
198
|
+
"PAB",
|
|
199
|
+
"PEI",
|
|
200
|
+
"PEN",
|
|
201
|
+
"PES",
|
|
202
|
+
"PGK",
|
|
203
|
+
"PHP",
|
|
204
|
+
"PKR",
|
|
205
|
+
"PLN",
|
|
206
|
+
"PLZ",
|
|
207
|
+
"PTE",
|
|
208
|
+
"PYG",
|
|
209
|
+
"QAR",
|
|
210
|
+
"RHD",
|
|
211
|
+
"ROL",
|
|
212
|
+
"RON",
|
|
213
|
+
"RSD",
|
|
214
|
+
"RUB",
|
|
215
|
+
"RUR",
|
|
216
|
+
"RWF",
|
|
217
|
+
"SAR",
|
|
218
|
+
"SBD",
|
|
219
|
+
"SCR",
|
|
220
|
+
"SDD",
|
|
221
|
+
"SDG",
|
|
222
|
+
"SDP",
|
|
223
|
+
"SEK",
|
|
224
|
+
"SGD",
|
|
225
|
+
"SHP",
|
|
226
|
+
"SIT",
|
|
227
|
+
"SKK",
|
|
228
|
+
"SLE",
|
|
229
|
+
"SLL",
|
|
230
|
+
"SOS",
|
|
231
|
+
"SRD",
|
|
232
|
+
"SRG",
|
|
233
|
+
"SSP",
|
|
234
|
+
"STD",
|
|
235
|
+
"STN",
|
|
236
|
+
"SUR",
|
|
237
|
+
"SVC",
|
|
238
|
+
"SYP",
|
|
239
|
+
"SZL",
|
|
240
|
+
"THB",
|
|
241
|
+
"TJR",
|
|
242
|
+
"TJS",
|
|
243
|
+
"TMM",
|
|
244
|
+
"TMT",
|
|
245
|
+
"TND",
|
|
246
|
+
"TOP",
|
|
247
|
+
"TPE",
|
|
248
|
+
"TRL",
|
|
249
|
+
"TRY",
|
|
250
|
+
"TTD",
|
|
251
|
+
"TWD",
|
|
252
|
+
"TZS",
|
|
253
|
+
"UAH",
|
|
254
|
+
"UAK",
|
|
255
|
+
"UGS",
|
|
256
|
+
"UGX",
|
|
257
|
+
"USD",
|
|
258
|
+
"USN",
|
|
259
|
+
"USS",
|
|
260
|
+
"UYI",
|
|
261
|
+
"UYP",
|
|
262
|
+
"UYU",
|
|
263
|
+
"UYW",
|
|
264
|
+
"UZS",
|
|
265
|
+
"VEB",
|
|
266
|
+
"VED",
|
|
267
|
+
"VEF",
|
|
268
|
+
"VES",
|
|
269
|
+
"VND",
|
|
270
|
+
"VNN",
|
|
271
|
+
"VUV",
|
|
272
|
+
"WST",
|
|
273
|
+
"XAF",
|
|
274
|
+
"XAG",
|
|
275
|
+
"XAU",
|
|
276
|
+
"XBA",
|
|
277
|
+
"XBB",
|
|
278
|
+
"XBC",
|
|
279
|
+
"XBD",
|
|
280
|
+
"XCD",
|
|
281
|
+
"XCG",
|
|
282
|
+
"XDR",
|
|
283
|
+
"XEU",
|
|
284
|
+
"XFO",
|
|
285
|
+
"XFU",
|
|
286
|
+
"XOF",
|
|
287
|
+
"XPD",
|
|
288
|
+
"XPF",
|
|
289
|
+
"XPT",
|
|
290
|
+
"XRE",
|
|
291
|
+
"XSU",
|
|
292
|
+
"XTS",
|
|
293
|
+
"XUA",
|
|
294
|
+
"XXX",
|
|
295
|
+
"YDD",
|
|
296
|
+
"YER",
|
|
297
|
+
"YUD",
|
|
298
|
+
"YUM",
|
|
299
|
+
"YUN",
|
|
300
|
+
"YUR",
|
|
301
|
+
"ZAL",
|
|
302
|
+
"ZAR",
|
|
303
|
+
"ZMK",
|
|
304
|
+
"ZMW",
|
|
305
|
+
"ZRN",
|
|
306
|
+
"ZRZ",
|
|
307
|
+
"ZWD",
|
|
308
|
+
"ZWG",
|
|
309
|
+
"ZWL",
|
|
310
|
+
"ZWR"
|
|
311
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Calendar } from "./calendars.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* ECMA-402 Spec: Returns supported calendar identifiers
|
|
4
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
5
|
+
*
|
|
6
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSupportedCalendars(): Calendar[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createMemoizedDateTimeFormat } from "./memoize.js";
|
|
2
|
+
import { calendars } from "./calendars.generated.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation: Tests if a calendar is supported by attempting to create
|
|
5
|
+
* a DateTimeFormat with that calendar and verifying it was accepted.
|
|
6
|
+
*
|
|
7
|
+
* CLDR Data: Candidate values come from CLDR calendar types
|
|
8
|
+
*/
|
|
9
|
+
function isSupportedCalendar(item) {
|
|
10
|
+
try {
|
|
11
|
+
// Always use 'en' for testing
|
|
12
|
+
const dateTimeFormat = createMemoizedDateTimeFormat(`en-u-ca-${item}`);
|
|
13
|
+
const options = dateTimeFormat.resolvedOptions().calendar;
|
|
14
|
+
// Verify the calendar was actually accepted (resolved calendar matches requested)
|
|
15
|
+
return options === item;
|
|
16
|
+
} catch {}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* ECMA-402 Spec: Returns supported calendar identifiers
|
|
21
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
22
|
+
*
|
|
23
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
24
|
+
*/
|
|
25
|
+
export function getSupportedCalendars() {
|
|
26
|
+
return calendars.filter(isSupportedCalendar).sort();
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Collation } from "./collations.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* ECMA-402 Spec: Returns supported collation identifiers
|
|
4
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
5
|
+
*
|
|
6
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSupportedCollations(): Collation[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { collations } from "./collations.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* Implementation: Tests if a collation is supported by attempting to create
|
|
4
|
+
* a Collator with that collation and verifying it was accepted.
|
|
5
|
+
*
|
|
6
|
+
* CLDR Data: Candidate values come from CLDR collation types
|
|
7
|
+
*/
|
|
8
|
+
function isSupportedCollation(collation) {
|
|
9
|
+
try {
|
|
10
|
+
// Always use 'en' for testing
|
|
11
|
+
return Intl.Collator(`en-u-co-${collation}`).resolvedOptions().collation === collation;
|
|
12
|
+
} catch {}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* ECMA-402 Spec: Returns supported collation identifiers
|
|
17
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
18
|
+
*
|
|
19
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
20
|
+
*/
|
|
21
|
+
export function getSupportedCollations() {
|
|
22
|
+
return collations.filter(isSupportedCollation).sort();
|
|
23
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Currency } from "./currencies.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* ECMA-402 Spec: Returns supported currency identifiers
|
|
4
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
5
|
+
*
|
|
6
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSupportedCurrencies(): Currency[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createMemoizedNumberFormat } from "@formatjs/ecma402-abstract";
|
|
2
|
+
import { currencies } from "./currencies.generated.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation: Tests if a currency is supported by attempting to create
|
|
5
|
+
* a NumberFormat with that currency and verifying it was accepted.
|
|
6
|
+
*
|
|
7
|
+
* CLDR Data: Candidate values come from CLDR currency codes (ISO 4217)
|
|
8
|
+
*/
|
|
9
|
+
function isSupportedCurrency(currency) {
|
|
10
|
+
try {
|
|
11
|
+
// Always use 'en' for testing
|
|
12
|
+
const numberFormat = createMemoizedNumberFormat("en", {
|
|
13
|
+
style: "currency",
|
|
14
|
+
currencyDisplay: "name",
|
|
15
|
+
currency
|
|
16
|
+
});
|
|
17
|
+
const format = numberFormat.format(123);
|
|
18
|
+
if (format.substring(0, 3) !== currency && format.substring(format.length - 3) !== currency) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
} catch {}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* ECMA-402 Spec: Returns supported currency identifiers
|
|
26
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
27
|
+
*
|
|
28
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
29
|
+
*/
|
|
30
|
+
export function getSupportedCurrencies() {
|
|
31
|
+
const ATOZ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
32
|
+
const supportedCurrencies = [];
|
|
33
|
+
for (const currency of currencies) {
|
|
34
|
+
if (currency.length === 3) {
|
|
35
|
+
if (isSupportedCurrency(currency)) {
|
|
36
|
+
supportedCurrencies.push(currency);
|
|
37
|
+
}
|
|
38
|
+
} else if (currency.length === 5 && currency[3] === "~") {
|
|
39
|
+
const start = ATOZ.indexOf(currency[2]);
|
|
40
|
+
const end = ATOZ.indexOf(currency[4]);
|
|
41
|
+
for (let i = start; i <= end; i++) {
|
|
42
|
+
const currentCurrency = currency.substring(0, 2) + ATOZ[i];
|
|
43
|
+
if (isSupportedCurrency(currentCurrency)) {
|
|
44
|
+
supportedCurrencies.push(currentCurrency);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return supportedCurrencies.sort();
|
|
50
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECMA-402 Spec: Returns supported numbering system identifiers
|
|
3
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
4
|
+
*
|
|
5
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
6
|
+
*/
|
|
7
|
+
export declare function getSupportedNumberingSystems(): string[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createMemoizedNumberFormat } from "@formatjs/ecma402-abstract";
|
|
2
|
+
import { numberingSystemNames } from "./numbering-systems.generated.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation: Tests if a numbering system is supported by attempting to create
|
|
5
|
+
* a NumberFormat with that numbering system and verifying it was accepted.
|
|
6
|
+
*
|
|
7
|
+
* CLDR Data: Candidate values come from CLDR numbering system types
|
|
8
|
+
*/
|
|
9
|
+
function isSupportedNumberingSystem(system) {
|
|
10
|
+
try {
|
|
11
|
+
// Always use 'en' for testing
|
|
12
|
+
const numberFormat = createMemoizedNumberFormat(`en-u-nu-${system}`);
|
|
13
|
+
const options = numberFormat.resolvedOptions().numberingSystem;
|
|
14
|
+
if (options === system && system === "latn" || numberFormat.format(123) !== "123") {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
} catch {}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ECMA-402 Spec: Returns supported numbering system identifiers
|
|
22
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
23
|
+
*
|
|
24
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
25
|
+
*/
|
|
26
|
+
export function getSupportedNumberingSystems() {
|
|
27
|
+
return numberingSystemNames.filter(isSupportedNumberingSystem).sort();
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Timezone } from "./timezones.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* ECMA-402 Spec: Returns supported timezone identifiers
|
|
4
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
5
|
+
*
|
|
6
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
7
|
+
*/
|
|
8
|
+
export declare function getSupportedTimeZones(): Timezone[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createMemoizedDateTimeFormat } from "./memoize.js";
|
|
2
|
+
import { timezones } from "./timezones.generated.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation: Tests if a timezone is supported by attempting to create
|
|
5
|
+
* a DateTimeFormat with that timezone and verifying it was accepted.
|
|
6
|
+
*
|
|
7
|
+
* CLDR Data: Candidate values come from IANA Time Zone Database
|
|
8
|
+
*/
|
|
9
|
+
function isSupportedTimeZone(timeZone) {
|
|
10
|
+
try {
|
|
11
|
+
// Always use 'en' for testing
|
|
12
|
+
const formatter = createMemoizedDateTimeFormat("en", { timeZone });
|
|
13
|
+
return formatter.resolvedOptions().timeZone === timeZone;
|
|
14
|
+
} catch {}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* ECMA-402 Spec: Returns supported timezone identifiers
|
|
19
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
20
|
+
*
|
|
21
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
22
|
+
*/
|
|
23
|
+
export function getSupportedTimeZones() {
|
|
24
|
+
return timezones.filter(isSupportedTimeZone).sort();
|
|
25
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECMA-402 Spec: Returns supported unit identifiers
|
|
3
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
4
|
+
*
|
|
5
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
6
|
+
*/
|
|
7
|
+
export declare function getSupportedUnits(): ("degree" | "acre" | "hectare" | "percent" | "bit" | "byte" | "gigabit" | "gigabyte" | "kilobit" | "kilobyte" | "megabit" | "megabyte" | "petabyte" | "terabit" | "terabyte" | "day" | "hour" | "millisecond" | "minute" | "month" | "second" | "week" | "year" | "centimeter" | "foot" | "inch" | "kilometer" | "meter" | "mile-scandinavian" | "mile" | "millimeter" | "yard" | "gram" | "kilogram" | "ounce" | "pound" | "stone" | "celsius" | "fahrenheit" | "fluid-ounce" | "gallon" | "liter" | "milliliter")[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createMemoizedNumberFormat } from "@formatjs/ecma402-abstract";
|
|
2
|
+
import { units } from "./units.generated.js";
|
|
3
|
+
/**
|
|
4
|
+
* Implementation: Tests if a unit is supported by attempting to create
|
|
5
|
+
* a NumberFormat with that unit and verifying it was accepted.
|
|
6
|
+
*
|
|
7
|
+
* CLDR Data: Candidate values come from CLDR unit types
|
|
8
|
+
*/
|
|
9
|
+
function isSupportedUnit(unit) {
|
|
10
|
+
try {
|
|
11
|
+
// Always use 'en' for testing
|
|
12
|
+
const formatter = createMemoizedNumberFormat("en", {
|
|
13
|
+
style: "unit",
|
|
14
|
+
unit
|
|
15
|
+
});
|
|
16
|
+
return formatter.resolvedOptions().unit === unit;
|
|
17
|
+
} catch {}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* ECMA-402 Spec: Returns supported unit identifiers
|
|
22
|
+
* ECMA-402 Spec: Results must be sorted lexicographically
|
|
23
|
+
*
|
|
24
|
+
* Implementation: Filters CLDR list against actual runtime support
|
|
25
|
+
*/
|
|
26
|
+
export function getSupportedUnits() {
|
|
27
|
+
return units.filter(isSupportedUnit).sort();
|
|
28
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ECMA-402 Spec: Intl.supportedValuesOf
|
|
3
|
+
* https://tc39.es/ecma402/#sec-intl.supportedvaluesof
|
|
4
|
+
*/
|
|
5
|
+
declare global {
|
|
6
|
+
namespace Intl {
|
|
7
|
+
/**
|
|
8
|
+
* Returns an array containing the supported values for the given key.
|
|
9
|
+
* @param key - The category of values to return
|
|
10
|
+
* @returns A sorted array of strings
|
|
11
|
+
*/
|
|
12
|
+
function supportedValuesOf(key: "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit"): string[];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* ECMA-402 Spec: Supported value categories
|
|
17
|
+
*/
|
|
18
|
+
export type SupportedValuesOf = "calendar" | "collation" | "currency" | "numberingSystem" | "timeZone" | "unit";
|
|
19
|
+
/**
|
|
20
|
+
* ECMA-402 Spec: Intl.supportedValuesOf(key)
|
|
21
|
+
* https://tc39.es/ecma402/#sec-intl.supportedvaluesof
|
|
22
|
+
*
|
|
23
|
+
* Returns an array containing the supported calendar, collation, currency,
|
|
24
|
+
* numbering systems, time zone, or unit values supported by the implementation.
|
|
25
|
+
*
|
|
26
|
+
* Implementation: We validate candidate values from CLDR against the actual
|
|
27
|
+
* Intl formatters to determine runtime support rather than using static lists.
|
|
28
|
+
* This ensures accuracy across different JavaScript engines and runtimes.
|
|
29
|
+
*
|
|
30
|
+
* @param key - The category of values to return
|
|
31
|
+
* @returns A sorted array of unique string values
|
|
32
|
+
*/
|
|
33
|
+
export declare function supportedValuesOf(key: SupportedValuesOf): string[];
|