@formatjs/intl-pluralrules 6.3.13 → 6.3.15
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 +9 -8
- package/index.js +519 -154
- package/index.js.map +1 -1
- package/locale-data/ca.js +2 -2
- package/locale-data/es.js +2 -2
- package/locale-data/fr.js +2 -2
- package/locale-data/it.js +2 -2
- package/locale-data/lld.js +2 -2
- package/locale-data/pt-PT.js +2 -2
- package/locale-data/pt.js +2 -2
- package/locale-data/scn.js +2 -2
- package/locale-data/vec.js +2 -2
- package/package.json +2 -2
- package/polyfill-force.d.ts +1 -1
- package/polyfill-force.js +519 -156
- package/polyfill-force.js.map +1 -1
- package/polyfill.d.ts +1 -1
- package/polyfill.iife.js +1018 -179
- package/polyfill.js +519 -154
- package/polyfill.js.map +1 -1
- package/should-polyfill.d.ts +1 -2
package/index.js
CHANGED
|
@@ -1,5 +1,393 @@
|
|
|
1
1
|
import { LookupSupportedLocales, ResolveLocale } from "@formatjs/intl-localematcher";
|
|
2
2
|
import Decimal$1, { Decimal } from "@formatjs/bigdecimal";
|
|
3
|
+
//#region node_modules/.aspect_rules_js/@formatjs_generated+cldr.supported-locales@0.0.0/node_modules/@formatjs_generated/cldr.supported-locales/default-content.js
|
|
4
|
+
const defaultContent = {
|
|
5
|
+
"aa": ["aa-ET"],
|
|
6
|
+
"ab": ["ab-GE"],
|
|
7
|
+
"af": ["af-ZA"],
|
|
8
|
+
"agq": ["agq-CM"],
|
|
9
|
+
"ak": ["ak-GH"],
|
|
10
|
+
"am": ["am-ET"],
|
|
11
|
+
"an": ["an-ES"],
|
|
12
|
+
"ann": ["ann-NG"],
|
|
13
|
+
"apc": ["apc-SY"],
|
|
14
|
+
"ar": ["ar-001"],
|
|
15
|
+
"arn": ["arn-CL"],
|
|
16
|
+
"as": ["as-IN"],
|
|
17
|
+
"asa": ["asa-TZ"],
|
|
18
|
+
"ast": ["ast-ES"],
|
|
19
|
+
"az-Arab": ["az-Arab-IR"],
|
|
20
|
+
"az-Cyrl": ["az-Cyrl-AZ"],
|
|
21
|
+
"az-Latn": ["az-Latn-AZ"],
|
|
22
|
+
"ba": ["ba-RU"],
|
|
23
|
+
"bal-Arab": ["bal-Arab-PK"],
|
|
24
|
+
"bal-Latn": ["bal-Latn-PK"],
|
|
25
|
+
"bas": ["bas-CM"],
|
|
26
|
+
"be": ["be-BY"],
|
|
27
|
+
"bem": ["bem-ZM"],
|
|
28
|
+
"bew": ["bew-ID"],
|
|
29
|
+
"bez": ["bez-TZ"],
|
|
30
|
+
"bg": ["bg-BG"],
|
|
31
|
+
"bgc": ["bgc-IN"],
|
|
32
|
+
"bgn": ["bgn-PK"],
|
|
33
|
+
"bho": ["bho-IN"],
|
|
34
|
+
"blo": ["blo-BJ"],
|
|
35
|
+
"blt": ["blt-VN"],
|
|
36
|
+
"bm": ["bm-ML"],
|
|
37
|
+
"bm-Nkoo": ["bm-Nkoo-ML"],
|
|
38
|
+
"bn": ["bn-BD"],
|
|
39
|
+
"bo": ["bo-CN"],
|
|
40
|
+
"bqi": ["bqi-IR"],
|
|
41
|
+
"br": ["br-FR"],
|
|
42
|
+
"brx": ["brx-IN"],
|
|
43
|
+
"bs-Cyrl": ["bs-Cyrl-BA"],
|
|
44
|
+
"bs-Latn": ["bs-Latn-BA"],
|
|
45
|
+
"bss": ["bss-CM"],
|
|
46
|
+
"bua": ["bua-RU"],
|
|
47
|
+
"byn": ["byn-ER"],
|
|
48
|
+
"ca": ["ca-ES"],
|
|
49
|
+
"cad": ["cad-US"],
|
|
50
|
+
"cch": ["cch-NG"],
|
|
51
|
+
"ccp": ["ccp-BD"],
|
|
52
|
+
"ce": ["ce-RU"],
|
|
53
|
+
"ceb": ["ceb-PH"],
|
|
54
|
+
"cgg": ["cgg-UG"],
|
|
55
|
+
"cho": ["cho-US"],
|
|
56
|
+
"chr": ["chr-US"],
|
|
57
|
+
"cic": ["cic-US"],
|
|
58
|
+
"ckb": ["ckb-IQ"],
|
|
59
|
+
"co": ["co-FR"],
|
|
60
|
+
"cop": ["cop-EG"],
|
|
61
|
+
"cs": ["cs-CZ"],
|
|
62
|
+
"csw": ["csw-CA"],
|
|
63
|
+
"cu": ["cu-RU"],
|
|
64
|
+
"cv": ["cv-RU"],
|
|
65
|
+
"cy": ["cy-GB"],
|
|
66
|
+
"da": ["da-DK"],
|
|
67
|
+
"dav": ["dav-KE"],
|
|
68
|
+
"de": ["de-DE"],
|
|
69
|
+
"dje": ["dje-NE"],
|
|
70
|
+
"doi": ["doi-IN"],
|
|
71
|
+
"dsb": ["dsb-DE"],
|
|
72
|
+
"dua": ["dua-CM"],
|
|
73
|
+
"dv": ["dv-MV"],
|
|
74
|
+
"dyo": ["dyo-SN"],
|
|
75
|
+
"dz": ["dz-BT"],
|
|
76
|
+
"ebu": ["ebu-KE"],
|
|
77
|
+
"ee": ["ee-GH"],
|
|
78
|
+
"el": ["el-GR"],
|
|
79
|
+
"en-Dsrt": ["en-Dsrt-US"],
|
|
80
|
+
"en-Shaw": ["en-Shaw-GB"],
|
|
81
|
+
"en": ["en-US"],
|
|
82
|
+
"eo": ["eo-001"],
|
|
83
|
+
"es": ["es-ES"],
|
|
84
|
+
"et": ["et-EE"],
|
|
85
|
+
"eu": ["eu-ES"],
|
|
86
|
+
"ewo": ["ewo-CM"],
|
|
87
|
+
"fa": ["fa-IR"],
|
|
88
|
+
"ff-Adlm": ["ff-Adlm-GN"],
|
|
89
|
+
"ff-Latn": ["ff-Latn-SN"],
|
|
90
|
+
"fi": ["fi-FI"],
|
|
91
|
+
"fil": ["fil-PH"],
|
|
92
|
+
"fo": ["fo-FO"],
|
|
93
|
+
"fr": ["fr-FR"],
|
|
94
|
+
"frr": ["frr-DE"],
|
|
95
|
+
"fur": ["fur-IT"],
|
|
96
|
+
"fy": ["fy-NL"],
|
|
97
|
+
"ga": ["ga-IE"],
|
|
98
|
+
"gaa": ["gaa-GH"],
|
|
99
|
+
"gd": ["gd-GB"],
|
|
100
|
+
"gez": ["gez-ET"],
|
|
101
|
+
"gl": ["gl-ES"],
|
|
102
|
+
"gn": ["gn-PY"],
|
|
103
|
+
"gsw": ["gsw-CH"],
|
|
104
|
+
"gu": ["gu-IN"],
|
|
105
|
+
"guz": ["guz-KE"],
|
|
106
|
+
"gv": ["gv-IM"],
|
|
107
|
+
"ha-Arab": ["ha-Arab-NG"],
|
|
108
|
+
"ha": ["ha-NG"],
|
|
109
|
+
"haw": ["haw-US"],
|
|
110
|
+
"he": ["he-IL"],
|
|
111
|
+
"hi": ["hi-IN"],
|
|
112
|
+
"hi-Latn": ["hi-Latn-IN"],
|
|
113
|
+
"hnj-Hmnp": ["hnj-Hmnp-US"],
|
|
114
|
+
"hr": ["hr-HR"],
|
|
115
|
+
"hsb": ["hsb-DE"],
|
|
116
|
+
"ht": ["ht-HT"],
|
|
117
|
+
"hu": ["hu-HU"],
|
|
118
|
+
"hy": ["hy-AM"],
|
|
119
|
+
"ia": ["ia-001"],
|
|
120
|
+
"id": ["id-ID"],
|
|
121
|
+
"ie": ["ie-EE"],
|
|
122
|
+
"ig": ["ig-NG"],
|
|
123
|
+
"ii": ["ii-CN"],
|
|
124
|
+
"io": ["io-001"],
|
|
125
|
+
"is": ["is-IS"],
|
|
126
|
+
"it": ["it-IT"],
|
|
127
|
+
"iu": ["iu-CA"],
|
|
128
|
+
"iu-Latn": ["iu-Latn-CA"],
|
|
129
|
+
"ja": ["ja-JP"],
|
|
130
|
+
"jbo": ["jbo-001"],
|
|
131
|
+
"jgo": ["jgo-CM"],
|
|
132
|
+
"jmc": ["jmc-TZ"],
|
|
133
|
+
"jv": ["jv-ID"],
|
|
134
|
+
"ka": ["ka-GE"],
|
|
135
|
+
"kaa-Cyrl": ["kaa-Cyrl-UZ"],
|
|
136
|
+
"kaa-Latn": ["kaa-Latn-UZ"],
|
|
137
|
+
"kab": ["kab-DZ"],
|
|
138
|
+
"kaj": ["kaj-NG"],
|
|
139
|
+
"kam": ["kam-KE"],
|
|
140
|
+
"kcg": ["kcg-NG"],
|
|
141
|
+
"kde": ["kde-TZ"],
|
|
142
|
+
"kea": ["kea-CV"],
|
|
143
|
+
"kek": ["kek-GT"],
|
|
144
|
+
"ken": ["ken-CM"],
|
|
145
|
+
"kgp": ["kgp-BR"],
|
|
146
|
+
"khq": ["khq-ML"],
|
|
147
|
+
"ki": ["ki-KE"],
|
|
148
|
+
"kk-Arab": ["kk-Arab-CN"],
|
|
149
|
+
"kk-Cyrl": ["kk-Cyrl-KZ"],
|
|
150
|
+
"kkj": ["kkj-CM"],
|
|
151
|
+
"kl": ["kl-GL"],
|
|
152
|
+
"kln": ["kln-KE"],
|
|
153
|
+
"km": ["km-KH"],
|
|
154
|
+
"kn": ["kn-IN"],
|
|
155
|
+
"ko": ["ko-KR"],
|
|
156
|
+
"kok-Deva": ["kok-Deva-IN"],
|
|
157
|
+
"kok-Latn": ["kok-Latn-IN"],
|
|
158
|
+
"kpe": ["kpe-LR"],
|
|
159
|
+
"ks-Arab": ["ks-Arab-IN"],
|
|
160
|
+
"ks-Deva": ["ks-Deva-IN"],
|
|
161
|
+
"ksb": ["ksb-TZ"],
|
|
162
|
+
"ksf": ["ksf-CM"],
|
|
163
|
+
"ksh": ["ksh-DE"],
|
|
164
|
+
"ku-Arab": ["ku-Arab-IQ"],
|
|
165
|
+
"ku-Latn": ["ku-Latn-TR"],
|
|
166
|
+
"kw": ["kw-GB"],
|
|
167
|
+
"kxv-Deva": ["kxv-Deva-IN"],
|
|
168
|
+
"kxv-Latn": ["kxv-Latn-IN"],
|
|
169
|
+
"kxv-Orya": ["kxv-Orya-IN"],
|
|
170
|
+
"kxv-Telu": ["kxv-Telu-IN"],
|
|
171
|
+
"ky": ["ky-KG"],
|
|
172
|
+
"la": ["la-VA"],
|
|
173
|
+
"lag": ["lag-TZ"],
|
|
174
|
+
"lb": ["lb-LU"],
|
|
175
|
+
"lg": ["lg-UG"],
|
|
176
|
+
"lij": ["lij-IT"],
|
|
177
|
+
"lkt": ["lkt-US"],
|
|
178
|
+
"lld": ["lld-IT"],
|
|
179
|
+
"lmo": ["lmo-IT"],
|
|
180
|
+
"ln": ["ln-CD"],
|
|
181
|
+
"lo": ["lo-LA"],
|
|
182
|
+
"lrc": ["lrc-IR"],
|
|
183
|
+
"lt": ["lt-LT"],
|
|
184
|
+
"ltg": ["ltg-LV"],
|
|
185
|
+
"lu": ["lu-CD"],
|
|
186
|
+
"luo": ["luo-KE"],
|
|
187
|
+
"luy": ["luy-KE"],
|
|
188
|
+
"lv": ["lv-LV"],
|
|
189
|
+
"lzz": ["lzz-TR"],
|
|
190
|
+
"mai": ["mai-IN"],
|
|
191
|
+
"mas": ["mas-KE"],
|
|
192
|
+
"mdf": ["mdf-RU"],
|
|
193
|
+
"mer": ["mer-KE"],
|
|
194
|
+
"mfe": ["mfe-MU"],
|
|
195
|
+
"mg": ["mg-MG"],
|
|
196
|
+
"mgh": ["mgh-MZ"],
|
|
197
|
+
"mgo": ["mgo-CM"],
|
|
198
|
+
"mhn": ["mhn-IT"],
|
|
199
|
+
"mi": ["mi-NZ"],
|
|
200
|
+
"mic": ["mic-CA"],
|
|
201
|
+
"mk": ["mk-MK"],
|
|
202
|
+
"ml": ["ml-IN"],
|
|
203
|
+
"mn": ["mn-MN"],
|
|
204
|
+
"mn-Mong": ["mn-Mong-CN"],
|
|
205
|
+
"mni-Beng": ["mni-Beng-IN"],
|
|
206
|
+
"mni-Mtei": ["mni-Mtei-IN"],
|
|
207
|
+
"moh": ["moh-CA"],
|
|
208
|
+
"mr": ["mr-IN"],
|
|
209
|
+
"ms-Arab": ["ms-Arab-MY"],
|
|
210
|
+
"ms": ["ms-MY"],
|
|
211
|
+
"mt": ["mt-MT"],
|
|
212
|
+
"mua": ["mua-CM"],
|
|
213
|
+
"mus": ["mus-US"],
|
|
214
|
+
"mww-Hmnp": ["mww-Hmnp-US"],
|
|
215
|
+
"my": ["my-MM"],
|
|
216
|
+
"myv": ["myv-RU"],
|
|
217
|
+
"mzn": ["mzn-IR"],
|
|
218
|
+
"naq": ["naq-NA"],
|
|
219
|
+
"nb": ["nb-NO"],
|
|
220
|
+
"nd": ["nd-ZW"],
|
|
221
|
+
"nds": ["nds-DE"],
|
|
222
|
+
"ne": ["ne-NP"],
|
|
223
|
+
"nl": ["nl-NL"],
|
|
224
|
+
"nmg": ["nmg-CM"],
|
|
225
|
+
"nn": ["nn-NO"],
|
|
226
|
+
"nnh": ["nnh-CM"],
|
|
227
|
+
"nqo": ["nqo-GN"],
|
|
228
|
+
"nr": ["nr-ZA"],
|
|
229
|
+
"nso": ["nso-ZA"],
|
|
230
|
+
"nus": ["nus-SS"],
|
|
231
|
+
"nv": ["nv-US"],
|
|
232
|
+
"ny": ["ny-MW"],
|
|
233
|
+
"nyn": ["nyn-UG"],
|
|
234
|
+
"oc": ["oc-FR"],
|
|
235
|
+
"oka": ["oka-CA"],
|
|
236
|
+
"om": ["om-ET"],
|
|
237
|
+
"or": ["or-IN"],
|
|
238
|
+
"os": ["os-GE"],
|
|
239
|
+
"osa": ["osa-US"],
|
|
240
|
+
"pa-Arab": ["pa-Arab-PK"],
|
|
241
|
+
"pa-Guru": ["pa-Guru-IN"],
|
|
242
|
+
"pap": ["pap-CW"],
|
|
243
|
+
"pcm": ["pcm-NG"],
|
|
244
|
+
"pi-Latn": ["pi-Latn-GB"],
|
|
245
|
+
"pis": ["pis-SB"],
|
|
246
|
+
"pl": ["pl-PL"],
|
|
247
|
+
"pms": ["pms-IT"],
|
|
248
|
+
"prg": ["prg-PL"],
|
|
249
|
+
"ps": ["ps-AF"],
|
|
250
|
+
"pt": ["pt-BR"],
|
|
251
|
+
"qu": ["qu-PE"],
|
|
252
|
+
"quc": ["quc-GT"],
|
|
253
|
+
"raj": ["raj-IN"],
|
|
254
|
+
"rhg-Rohg": ["rhg-Rohg-MM"],
|
|
255
|
+
"rif": ["rif-MA"],
|
|
256
|
+
"rm": ["rm-CH"],
|
|
257
|
+
"rn": ["rn-BI"],
|
|
258
|
+
"ro": ["ro-RO"],
|
|
259
|
+
"rof": ["rof-TZ"],
|
|
260
|
+
"ru": ["ru-RU"],
|
|
261
|
+
"rw": ["rw-RW"],
|
|
262
|
+
"rwk": ["rwk-TZ"],
|
|
263
|
+
"sa": ["sa-IN"],
|
|
264
|
+
"sah": ["sah-RU"],
|
|
265
|
+
"saq": ["saq-KE"],
|
|
266
|
+
"sat-Deva": ["sat-Deva-IN"],
|
|
267
|
+
"sat-Olck": ["sat-Olck-IN"],
|
|
268
|
+
"sbp": ["sbp-TZ"],
|
|
269
|
+
"sc": ["sc-IT"],
|
|
270
|
+
"scn": ["scn-IT"],
|
|
271
|
+
"sd-Arab": ["sd-Arab-PK"],
|
|
272
|
+
"sd-Deva": ["sd-Deva-IN"],
|
|
273
|
+
"sdh": ["sdh-IR"],
|
|
274
|
+
"se": ["se-NO"],
|
|
275
|
+
"seh": ["seh-MZ"],
|
|
276
|
+
"ses": ["ses-ML"],
|
|
277
|
+
"sg": ["sg-CF"],
|
|
278
|
+
"sgs": ["sgs-LT"],
|
|
279
|
+
"shi-Latn": ["shi-Latn-MA"],
|
|
280
|
+
"shi-Tfng": ["shi-Tfng-MA"],
|
|
281
|
+
"shn": ["shn-MM"],
|
|
282
|
+
"si": ["si-LK"],
|
|
283
|
+
"sid": ["sid-ET"],
|
|
284
|
+
"sk": ["sk-SK"],
|
|
285
|
+
"skr": ["skr-PK"],
|
|
286
|
+
"sl": ["sl-SI"],
|
|
287
|
+
"sma": ["sma-SE"],
|
|
288
|
+
"smj": ["smj-SE"],
|
|
289
|
+
"smn": ["smn-FI"],
|
|
290
|
+
"sms": ["sms-FI"],
|
|
291
|
+
"sn": ["sn-ZW"],
|
|
292
|
+
"so": ["so-SO"],
|
|
293
|
+
"sq": ["sq-AL"],
|
|
294
|
+
"sr-Cyrl": ["sr-Cyrl-RS"],
|
|
295
|
+
"sr-Latn": ["sr-Latn-RS"],
|
|
296
|
+
"ss": ["ss-ZA"],
|
|
297
|
+
"ssy": ["ssy-ER"],
|
|
298
|
+
"st": ["st-ZA"],
|
|
299
|
+
"su-Latn": ["su-Latn-ID"],
|
|
300
|
+
"suz-Deva": ["suz-Deva-NP"],
|
|
301
|
+
"suz-Sunu": ["suz-Sunu-NP"],
|
|
302
|
+
"sv": ["sv-SE"],
|
|
303
|
+
"sw": ["sw-TZ"],
|
|
304
|
+
"syr": ["syr-IQ"],
|
|
305
|
+
"szl": ["szl-PL"],
|
|
306
|
+
"ta": ["ta-IN"],
|
|
307
|
+
"te": ["te-IN"],
|
|
308
|
+
"teo": ["teo-UG"],
|
|
309
|
+
"tg": ["tg-TJ"],
|
|
310
|
+
"th": ["th-TH"],
|
|
311
|
+
"ti": ["ti-ET"],
|
|
312
|
+
"tig": ["tig-ER"],
|
|
313
|
+
"tk": ["tk-TM"],
|
|
314
|
+
"tn": ["tn-ZA"],
|
|
315
|
+
"to": ["to-TO"],
|
|
316
|
+
"tok": ["tok-001"],
|
|
317
|
+
"tpi": ["tpi-PG"],
|
|
318
|
+
"tr": ["tr-TR"],
|
|
319
|
+
"trv": ["trv-TW"],
|
|
320
|
+
"trw": ["trw-PK"],
|
|
321
|
+
"ts": ["ts-ZA"],
|
|
322
|
+
"tt": ["tt-RU"],
|
|
323
|
+
"twq": ["twq-NE"],
|
|
324
|
+
"tyv": ["tyv-RU"],
|
|
325
|
+
"tzm": ["tzm-MA"],
|
|
326
|
+
"ug": ["ug-CN"],
|
|
327
|
+
"uk": ["uk-UA"],
|
|
328
|
+
"ur": ["ur-PK"],
|
|
329
|
+
"uz-Arab": ["uz-Arab-AF"],
|
|
330
|
+
"uz-Cyrl": ["uz-Cyrl-UZ"],
|
|
331
|
+
"uz-Latn": ["uz-Latn-UZ"],
|
|
332
|
+
"vai-Latn": ["vai-Latn-LR"],
|
|
333
|
+
"vai-Vaii": ["vai-Vaii-LR"],
|
|
334
|
+
"ve": ["ve-ZA"],
|
|
335
|
+
"vec": ["vec-IT"],
|
|
336
|
+
"vi": ["vi-VN"],
|
|
337
|
+
"vmw": ["vmw-MZ"],
|
|
338
|
+
"vo": ["vo-001"],
|
|
339
|
+
"vun": ["vun-TZ"],
|
|
340
|
+
"wa": ["wa-BE"],
|
|
341
|
+
"wae": ["wae-CH"],
|
|
342
|
+
"wal": ["wal-ET"],
|
|
343
|
+
"wbp": ["wbp-AU"],
|
|
344
|
+
"wo": ["wo-SN"],
|
|
345
|
+
"xh": ["xh-ZA"],
|
|
346
|
+
"xnr": ["xnr-IN"],
|
|
347
|
+
"xog": ["xog-UG"],
|
|
348
|
+
"yav": ["yav-CM"],
|
|
349
|
+
"yi": ["yi-UA"],
|
|
350
|
+
"yo": ["yo-NG"],
|
|
351
|
+
"yrl": ["yrl-BR"],
|
|
352
|
+
"yue-Hans": ["yue-Hans-CN"],
|
|
353
|
+
"yue-Hant": ["yue-Hant-HK"],
|
|
354
|
+
"za": ["za-CN"],
|
|
355
|
+
"zgh": ["zgh-MA"],
|
|
356
|
+
"zh-Hans": ["zh-Hans-CN"],
|
|
357
|
+
"zh-Hant": ["zh-Hant-TW"],
|
|
358
|
+
"zh-Latn": ["zh-Latn-CN"],
|
|
359
|
+
"zu": ["zu-ZA"]
|
|
360
|
+
};
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region packages/ecma402-abstract/registerLocaleData.js
|
|
363
|
+
const explicitLocales = /* @__PURE__ */ new WeakMap();
|
|
364
|
+
function registerLocaleData(locale, data, localeData, availableLocales) {
|
|
365
|
+
let loaded = explicitLocales.get(localeData);
|
|
366
|
+
if (!loaded) {
|
|
367
|
+
loaded = /* @__PURE__ */ new Set();
|
|
368
|
+
explicitLocales.set(localeData, loaded);
|
|
369
|
+
}
|
|
370
|
+
loaded.add(locale);
|
|
371
|
+
const locales = [locale, ...defaultContent[locale] || []];
|
|
372
|
+
for (const tag of locales) {
|
|
373
|
+
if (tag === locale || !loaded.has(tag) || localeData[tag] === void 0) localeData[tag] = data;
|
|
374
|
+
availableLocales.add(tag);
|
|
375
|
+
}
|
|
376
|
+
for (const tag of locales) {
|
|
377
|
+
const parts = tag.split("-");
|
|
378
|
+
const fallbacks = [];
|
|
379
|
+
while (parts.length > 1) {
|
|
380
|
+
if (parts.length > 2 && parts[1].length === 4) fallbacks.push([parts[0], ...parts.slice(2)].join("-"));
|
|
381
|
+
parts.pop();
|
|
382
|
+
fallbacks.push(parts.join("-"));
|
|
383
|
+
}
|
|
384
|
+
for (const fallback of fallbacks) {
|
|
385
|
+
if (localeData[fallback] === void 0) localeData[fallback] = localeData[tag];
|
|
386
|
+
availableLocales.add(fallback);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
//#endregion
|
|
3
391
|
//#region packages/ecma402-abstract/CanonicalizeLocaleList.js
|
|
4
392
|
/**
|
|
5
393
|
* http://ecma-international.org/ecma-402/7.0/index.html#sec-canonicalizelocalelist
|
|
@@ -37,7 +425,7 @@ function ToString(o) {
|
|
|
37
425
|
* @param fallback
|
|
38
426
|
*/
|
|
39
427
|
function GetOption(opts, prop, type, values, fallback) {
|
|
40
|
-
if (typeof opts !== "object") throw new TypeError("Options must be an object");
|
|
428
|
+
if (opts === null || typeof opts !== "object" && typeof opts !== "function") throw new TypeError("Options must be an object");
|
|
41
429
|
let value = opts[prop];
|
|
42
430
|
if (value !== void 0) {
|
|
43
431
|
if (type !== "boolean" && type !== "string") throw new TypeError("invalid type");
|
|
@@ -67,7 +455,7 @@ function SupportedLocales(availableLocales, requestedLocales, options) {
|
|
|
67
455
|
}
|
|
68
456
|
//#endregion
|
|
69
457
|
//#region packages/ecma262-abstract/ToPrimitive.js
|
|
70
|
-
function invariant$
|
|
458
|
+
function invariant$1(condition, message, Err = Error) {
|
|
71
459
|
if (!condition) throw new Err(message);
|
|
72
460
|
}
|
|
73
461
|
function IsCallable(fn) {
|
|
@@ -97,7 +485,7 @@ function ToPrimitive(input, preferredType) {
|
|
|
97
485
|
if (preferredType === void 0) hint = "default";
|
|
98
486
|
else if (preferredType === "string") hint = "string";
|
|
99
487
|
else {
|
|
100
|
-
invariant$
|
|
488
|
+
invariant$1(preferredType === "number", "preferredType must be \"string\" or \"number\"");
|
|
101
489
|
hint = "number";
|
|
102
490
|
}
|
|
103
491
|
let result = exoticToPrim.call(input, hint);
|
|
@@ -118,6 +506,7 @@ function ToPrimitive(input, preferredType) {
|
|
|
118
506
|
function ToIntlMathematicalValue(input) {
|
|
119
507
|
if (typeof input === "bigint") return new Decimal(input.toString());
|
|
120
508
|
let primValue = ToPrimitive(input, "number");
|
|
509
|
+
if (typeof primValue === "symbol") throw new TypeError("Cannot convert a Symbol value to a number");
|
|
121
510
|
if (primValue === void 0) return new Decimal(NaN);
|
|
122
511
|
if (primValue === true) return new Decimal(1);
|
|
123
512
|
if (primValue === false) return new Decimal(0);
|
|
@@ -142,7 +531,9 @@ function CoerceOptionsToObject(options) {
|
|
|
142
531
|
//#endregion
|
|
143
532
|
//#region packages/ecma402-abstract/DefaultNumberOption.js
|
|
144
533
|
/**
|
|
534
|
+
* ECMA-402 §9.2.13 DefaultNumberOption, step 2.
|
|
145
535
|
* https://tc39.es/ecma402/#sec-defaultnumberoption
|
|
536
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/negotiation.html#L437
|
|
146
537
|
* @param val
|
|
147
538
|
* @param min
|
|
148
539
|
* @param max
|
|
@@ -150,7 +541,7 @@ function CoerceOptionsToObject(options) {
|
|
|
150
541
|
*/
|
|
151
542
|
function DefaultNumberOption(inputVal, min, max, fallback) {
|
|
152
543
|
if (inputVal === void 0) return fallback;
|
|
153
|
-
const val =
|
|
544
|
+
const val = +inputVal;
|
|
154
545
|
if (isNaN(val) || val < min || val > max) throw new RangeError(`${val} is outside of range [${min}, ${max}]`);
|
|
155
546
|
return Math.floor(val);
|
|
156
547
|
}
|
|
@@ -242,7 +633,7 @@ function repeat(s, times) {
|
|
|
242
633
|
for (let i = 0; i < arr.length; i++) arr[i] = s;
|
|
243
634
|
return arr.join("");
|
|
244
635
|
}
|
|
245
|
-
function invariant
|
|
636
|
+
function invariant(condition, message, Err = Error) {
|
|
246
637
|
if (!condition) throw new Err(message);
|
|
247
638
|
}
|
|
248
639
|
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
@@ -278,8 +669,8 @@ function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefau
|
|
|
278
669
|
let mxsd = opts.maximumSignificantDigits;
|
|
279
670
|
internalSlots.minimumIntegerDigits = mnid;
|
|
280
671
|
const roundingIncrement = GetNumberOption(opts, "roundingIncrement", 1, 5e3, 1);
|
|
281
|
-
invariant
|
|
282
|
-
Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}
|
|
672
|
+
invariant(VALID_ROUNDING_INCREMENTS.has(roundingIncrement), `Invalid rounding increment value: ${roundingIncrement}.
|
|
673
|
+
Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`, RangeError);
|
|
283
674
|
const roundingMode = GetOption(opts, "roundingMode", "string", [
|
|
284
675
|
"ceil",
|
|
285
676
|
"floor",
|
|
@@ -309,26 +700,30 @@ Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`);
|
|
|
309
700
|
needSd = hasSd;
|
|
310
701
|
if (hasSd || !hasFd && notation === "compact") needFd = false;
|
|
311
702
|
}
|
|
312
|
-
if (needSd)
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
703
|
+
if (needSd) {
|
|
704
|
+
if (hasSd) {
|
|
705
|
+
internalSlots.minimumSignificantDigits = DefaultNumberOption(mnsd, 1, 21, 1);
|
|
706
|
+
internalSlots.maximumSignificantDigits = DefaultNumberOption(mxsd, internalSlots.minimumSignificantDigits, 21, 21);
|
|
707
|
+
} else {
|
|
708
|
+
internalSlots.minimumSignificantDigits = 1;
|
|
709
|
+
internalSlots.maximumSignificantDigits = 21;
|
|
710
|
+
}
|
|
318
711
|
}
|
|
319
|
-
if (needFd)
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
712
|
+
if (needFd) {
|
|
713
|
+
if (hasFd) {
|
|
714
|
+
mnfd = DefaultNumberOption(mnfd, 0, 100, void 0);
|
|
715
|
+
mxfd = DefaultNumberOption(mxfd, 0, 100, void 0);
|
|
716
|
+
if (mnfd === void 0) {
|
|
717
|
+
invariant(mxfd !== void 0, "maximumFractionDigits must be defined");
|
|
718
|
+
mnfd = Math.min(mnfdDefault, mxfd);
|
|
719
|
+
} else if (mxfd === void 0) mxfd = Math.max(mxfdDefault, mnfd);
|
|
720
|
+
else if (mnfd > mxfd) throw new RangeError(`Invalid range, ${mnfd} > ${mxfd}`);
|
|
721
|
+
internalSlots.minimumFractionDigits = mnfd;
|
|
722
|
+
internalSlots.maximumFractionDigits = mxfd;
|
|
723
|
+
} else {
|
|
724
|
+
internalSlots.minimumFractionDigits = mnfdDefault;
|
|
725
|
+
internalSlots.maximumFractionDigits = mxfdDefault;
|
|
726
|
+
}
|
|
332
727
|
}
|
|
333
728
|
if (!needSd && !needFd) {
|
|
334
729
|
internalSlots.minimumFractionDigits = 0;
|
|
@@ -351,8 +746,8 @@ Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`);
|
|
|
351
746
|
internalSlots.roundingPriority = "auto";
|
|
352
747
|
}
|
|
353
748
|
if (roundingIncrement !== 1) {
|
|
354
|
-
invariant
|
|
355
|
-
invariant
|
|
749
|
+
invariant(internalSlots.roundingType === "fractionDigits", "Invalid roundingType", TypeError);
|
|
750
|
+
invariant(internalSlots.maximumFractionDigits === internalSlots.minimumFractionDigits, "With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.", RangeError);
|
|
356
751
|
}
|
|
357
752
|
}
|
|
358
753
|
//#endregion
|
|
@@ -367,13 +762,19 @@ function InitializePluralRules(pl, locales, options, { availableLocales, relevan
|
|
|
367
762
|
const r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
368
763
|
internalSlots.locale = r.locale;
|
|
369
764
|
internalSlots.type = GetOption(opts, "type", "string", ["cardinal", "ordinal"], "cardinal");
|
|
370
|
-
const notation = GetOption(opts, "notation", "string", [
|
|
765
|
+
const notation = GetOption(opts, "notation", "string", [
|
|
766
|
+
"standard",
|
|
767
|
+
"scientific",
|
|
768
|
+
"engineering",
|
|
769
|
+
"compact"
|
|
770
|
+
], "standard");
|
|
371
771
|
internalSlots.notation = notation;
|
|
772
|
+
const compactDisplay = GetOption(opts, "compactDisplay", "string", ["short", "long"], "short");
|
|
372
773
|
if (notation === "compact") {
|
|
373
|
-
internalSlots.compactDisplay =
|
|
374
|
-
|
|
774
|
+
internalSlots.compactDisplay = compactDisplay;
|
|
775
|
+
internalSlots.compactExponents = localeData[r.dataLocale]?.compactExponents;
|
|
375
776
|
}
|
|
376
|
-
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3,
|
|
777
|
+
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, notation);
|
|
377
778
|
return pl;
|
|
378
779
|
}
|
|
379
780
|
//#endregion
|
|
@@ -392,62 +793,8 @@ function Type(x) {
|
|
|
392
793
|
if (typeof x === "bigint") return "BigInt";
|
|
393
794
|
}
|
|
394
795
|
//#endregion
|
|
395
|
-
//#region packages/ecma402-abstract/NumberFormat/decimal-cache.js
|
|
396
|
-
/**
|
|
397
|
-
* Cached function to compute powers of 10 for Decimal.js operations.
|
|
398
|
-
* This cache significantly reduces overhead in ComputeExponent and ToRawFixed
|
|
399
|
-
* by memoizing expensive Decimal.pow(10, n) calculations.
|
|
400
|
-
*
|
|
401
|
-
* Common exponents (e.g., -20 to 20) are used repeatedly in number formatting,
|
|
402
|
-
* so caching provides substantial performance benefits.
|
|
403
|
-
*
|
|
404
|
-
* @param exponent - Can be a number or Decimal. If Decimal, it will be converted to string for cache key.
|
|
405
|
-
*/
|
|
406
|
-
const getPowerOf10 = memoize((exponent) => {
|
|
407
|
-
return Decimal.pow(10, exponent);
|
|
408
|
-
});
|
|
409
|
-
//#endregion
|
|
410
|
-
//#region packages/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
|
|
411
|
-
/**
|
|
412
|
-
* The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
|
|
413
|
-
* number of the given magnitude (power of ten of the most significant digit) according to the
|
|
414
|
-
* locale and the desired notation (scientific, engineering, or compact).
|
|
415
|
-
*/
|
|
416
|
-
function ComputeExponentForMagnitude(internalSlots, magnitude) {
|
|
417
|
-
const { notation, dataLocaleData, numberingSystem } = internalSlots;
|
|
418
|
-
switch (notation) {
|
|
419
|
-
case "standard": return 0;
|
|
420
|
-
case "scientific": return magnitude.toNumber();
|
|
421
|
-
case "engineering": return magnitude.div(3).floor().times(3).toNumber();
|
|
422
|
-
default: {
|
|
423
|
-
invariant$1(notation === "compact", "Invalid notation");
|
|
424
|
-
const { compactDisplay, style, currencyDisplay } = internalSlots;
|
|
425
|
-
let thresholdMap;
|
|
426
|
-
if (style === "currency" && currencyDisplay !== "name") thresholdMap = (dataLocaleData.numbers.currency[numberingSystem] || dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]]).short;
|
|
427
|
-
else {
|
|
428
|
-
const decimal = dataLocaleData.numbers.decimal[numberingSystem] || dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
|
|
429
|
-
thresholdMap = compactDisplay === "long" ? decimal.long : decimal.short;
|
|
430
|
-
}
|
|
431
|
-
if (!thresholdMap) return 0;
|
|
432
|
-
const num = getPowerOf10(magnitude).toString();
|
|
433
|
-
const thresholds = Object.keys(thresholdMap);
|
|
434
|
-
if (num < thresholds[0]) return 0;
|
|
435
|
-
if (num > thresholds[thresholds.length - 1]) {
|
|
436
|
-
const magnitudeKey = thresholds[thresholds.length - 1];
|
|
437
|
-
if (thresholdMap[magnitudeKey].other === "0") return 0;
|
|
438
|
-
return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
|
|
439
|
-
}
|
|
440
|
-
const i = thresholds.indexOf(num);
|
|
441
|
-
if (i === -1) return 0;
|
|
442
|
-
const magnitudeKey = thresholds[i];
|
|
443
|
-
if (thresholdMap[magnitudeKey].other === "0") return 0;
|
|
444
|
-
return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
//#endregion
|
|
449
796
|
//#region packages/ecma402-abstract/constants.js
|
|
450
|
-
const ZERO
|
|
797
|
+
const ZERO = new Decimal(0);
|
|
451
798
|
const NEGATIVE_ZERO = new Decimal(-0);
|
|
452
799
|
//#endregion
|
|
453
800
|
//#region packages/ecma402-abstract/NumberFormat/GetUnsignedRoundingMode.js
|
|
@@ -482,21 +829,36 @@ function GetUnsignedRoundingMode(roundingMode, isNegative) {
|
|
|
482
829
|
function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
|
|
483
830
|
if (x.eq(r1) || r1.eq(r2)) return r1;
|
|
484
831
|
if (x.eq(r2)) return r2;
|
|
485
|
-
invariant
|
|
832
|
+
invariant(r1.lessThan(x) && x.lessThan(r2), `x should be between r1 and r2 but x=${x}, r1=${r1}, r2=${r2}`);
|
|
486
833
|
if (unsignedRoundingMode === "zero") return r1;
|
|
487
834
|
if (unsignedRoundingMode === "infinity") return r2;
|
|
488
835
|
const d1 = x.minus(r1);
|
|
489
836
|
const d2 = r2.minus(x);
|
|
490
837
|
if (d1.lessThan(d2)) return r1;
|
|
491
838
|
if (d2.lessThan(d1)) return r2;
|
|
492
|
-
invariant
|
|
839
|
+
invariant(d1.eq(d2), "d1 should be equal to d2");
|
|
493
840
|
if (unsignedRoundingMode === "half-zero") return r1;
|
|
494
841
|
if (unsignedRoundingMode === "half-infinity") return r2;
|
|
495
|
-
invariant
|
|
842
|
+
invariant(unsignedRoundingMode === "half-even", "unsignedRoundingMode should be half-even");
|
|
496
843
|
if (r1.div(r2.minus(r1)).mod(2).isZero()) return r1;
|
|
497
844
|
return r2;
|
|
498
845
|
}
|
|
499
846
|
//#endregion
|
|
847
|
+
//#region packages/ecma402-abstract/NumberFormat/decimal-cache.js
|
|
848
|
+
/**
|
|
849
|
+
* Cached function to compute powers of 10 for Decimal.js operations.
|
|
850
|
+
* This cache significantly reduces overhead in ComputeExponent and ToRawFixed
|
|
851
|
+
* by memoizing expensive Decimal.pow(10, n) calculations.
|
|
852
|
+
*
|
|
853
|
+
* Common exponents (e.g., -20 to 20) are used repeatedly in number formatting,
|
|
854
|
+
* so caching provides substantial performance benefits.
|
|
855
|
+
*
|
|
856
|
+
* @param exponent - Can be a number or Decimal. If Decimal, it will be converted to string for cache key.
|
|
857
|
+
*/
|
|
858
|
+
const getPowerOf10 = memoize((exponent) => {
|
|
859
|
+
return Decimal.pow(10, exponent);
|
|
860
|
+
});
|
|
861
|
+
//#endregion
|
|
500
862
|
//#region packages/ecma402-abstract/NumberFormat/ToRawFixed.js
|
|
501
863
|
function ToRawFixedFn(n, f) {
|
|
502
864
|
return n.times(getPowerOf10(-f));
|
|
@@ -654,7 +1016,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
654
1016
|
if (x.isZero()) {
|
|
655
1017
|
m = repeat("0", p);
|
|
656
1018
|
e = 0;
|
|
657
|
-
xFinal = ZERO
|
|
1019
|
+
xFinal = ZERO;
|
|
658
1020
|
} else {
|
|
659
1021
|
const { n1, e1, r1 } = findN1E1R1(x, p);
|
|
660
1022
|
const { n2, e2, r2 } = findN2E2R2(x, p);
|
|
@@ -679,7 +1041,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
679
1041
|
m = m.slice(0, e + 1) + "." + m.slice(m.length - (p - (e + 1)));
|
|
680
1042
|
int = e + 1;
|
|
681
1043
|
} else {
|
|
682
|
-
invariant
|
|
1044
|
+
invariant(e < 0, "e should be less than 0");
|
|
683
1045
|
m = "0." + repeat("0", -e - 1) + m;
|
|
684
1046
|
int = 1;
|
|
685
1047
|
}
|
|
@@ -695,7 +1057,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
695
1057
|
formattedString: m,
|
|
696
1058
|
roundedNumber: xFinal,
|
|
697
1059
|
integerDigitsCount: int,
|
|
698
|
-
roundingMagnitude: e
|
|
1060
|
+
roundingMagnitude: e - p + 1
|
|
699
1061
|
};
|
|
700
1062
|
}
|
|
701
1063
|
//#endregion
|
|
@@ -708,9 +1070,9 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
708
1070
|
let sign;
|
|
709
1071
|
if (x.isZero() && x.isNegative()) {
|
|
710
1072
|
sign = "negative";
|
|
711
|
-
x = ZERO
|
|
1073
|
+
x = ZERO;
|
|
712
1074
|
} else {
|
|
713
|
-
invariant
|
|
1075
|
+
invariant(x.isFinite(), "NumberFormatDigitInternalSlots value is not finite");
|
|
714
1076
|
if (x.lessThan(0)) sign = "negative";
|
|
715
1077
|
else sign = "positive";
|
|
716
1078
|
if (sign === "negative") x = x.negated();
|
|
@@ -728,14 +1090,14 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
728
1090
|
default:
|
|
729
1091
|
let sResult = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
|
|
730
1092
|
let fResult = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
|
|
731
|
-
if (intlObject.roundingType === "morePrecision")
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
1093
|
+
if (intlObject.roundingType === "morePrecision") {
|
|
1094
|
+
if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = sResult;
|
|
1095
|
+
else result = fResult;
|
|
1096
|
+
} else {
|
|
1097
|
+
invariant(intlObject.roundingType === "lessPrecision", "Invalid roundingType");
|
|
735
1098
|
if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = fResult;
|
|
736
1099
|
else result = sResult;
|
|
737
1100
|
}
|
|
738
|
-
break;
|
|
739
1101
|
}
|
|
740
1102
|
x = result.roundedNumber;
|
|
741
1103
|
let string = result.formattedString;
|
|
@@ -746,44 +1108,22 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
746
1108
|
const int = result.integerDigitsCount;
|
|
747
1109
|
const minInteger = intlObject.minimumIntegerDigits;
|
|
748
1110
|
if (int < minInteger) string = repeat("0", minInteger - int) + string;
|
|
749
|
-
if (sign === "negative")
|
|
750
|
-
|
|
1111
|
+
if (sign === "negative") {
|
|
1112
|
+
if (x.isZero()) x = NEGATIVE_ZERO;
|
|
1113
|
+
else x = x.negated();
|
|
1114
|
+
}
|
|
751
1115
|
return {
|
|
752
1116
|
roundedNumber: x,
|
|
753
1117
|
formattedString: string
|
|
754
1118
|
};
|
|
755
1119
|
}
|
|
756
1120
|
//#endregion
|
|
757
|
-
//#region packages/ecma262-abstract/ToNumber.js
|
|
758
|
-
const ZERO = new Decimal(0);
|
|
759
|
-
function invariant(condition, message, Err = Error) {
|
|
760
|
-
if (!condition) throw new Err(message);
|
|
761
|
-
}
|
|
762
|
-
/**
|
|
763
|
-
* https://tc39.es/ecma262/#sec-tonumber
|
|
764
|
-
*/
|
|
765
|
-
function ToNumber(arg) {
|
|
766
|
-
if (typeof arg === "number") return new Decimal(arg);
|
|
767
|
-
if (typeof arg === "bigint") return new Decimal(arg.toString());
|
|
768
|
-
invariant(typeof arg !== "symbol", "Symbol is not supported", TypeError);
|
|
769
|
-
if (arg === void 0) return new Decimal(NaN);
|
|
770
|
-
if (arg === null || arg === 0) return ZERO;
|
|
771
|
-
if (arg === true) return new Decimal(1);
|
|
772
|
-
if (typeof arg === "string") try {
|
|
773
|
-
return new Decimal(arg);
|
|
774
|
-
} catch {
|
|
775
|
-
return new Decimal(NaN);
|
|
776
|
-
}
|
|
777
|
-
invariant(typeof arg === "object", "object expected", TypeError);
|
|
778
|
-
let primValue = ToPrimitive(arg, "number");
|
|
779
|
-
invariant(typeof primValue !== "object", "object expected", TypeError);
|
|
780
|
-
return ToNumber(primValue);
|
|
781
|
-
}
|
|
782
|
-
//#endregion
|
|
783
1121
|
//#region packages/ecma402-abstract/PluralRules/GetOperands.js
|
|
784
1122
|
/**
|
|
785
|
-
*
|
|
786
|
-
*
|
|
1123
|
+
* CLDR operands for the implementation-defined PluralRuleSelect
|
|
1124
|
+
* ECMA-402 §17.5.1 PluralRuleSelect, decimalString parameter and return definition.
|
|
1125
|
+
* https://tc39.es/ecma402/#sec-pluralruleselect
|
|
1126
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/pluralrules.html#L285-L290
|
|
787
1127
|
*
|
|
788
1128
|
* Implementation: Extended to support compact exponent (c/e operands)
|
|
789
1129
|
*
|
|
@@ -791,34 +1131,34 @@ function ToNumber(arg) {
|
|
|
791
1131
|
* @param exponent Compact decimal exponent (c/e operand), defaults to 0
|
|
792
1132
|
*/
|
|
793
1133
|
function GetOperands(s, exponent = 0) {
|
|
794
|
-
invariant
|
|
795
|
-
const n =
|
|
796
|
-
invariant
|
|
1134
|
+
invariant(typeof s === "string", `GetOperands should have been called with a string`);
|
|
1135
|
+
const n = new Decimal$1(s);
|
|
1136
|
+
invariant(n.isFinite(), "n should be finite");
|
|
797
1137
|
let dp = s.indexOf(".");
|
|
798
1138
|
let iv;
|
|
799
1139
|
let f;
|
|
800
1140
|
let v;
|
|
801
1141
|
let fv = "";
|
|
802
1142
|
if (dp === -1) {
|
|
803
|
-
iv =
|
|
804
|
-
f = ZERO
|
|
1143
|
+
iv = s;
|
|
1144
|
+
f = ZERO;
|
|
805
1145
|
v = 0;
|
|
806
1146
|
} else {
|
|
807
1147
|
iv = s.slice(0, dp);
|
|
808
1148
|
fv = s.slice(dp, s.length);
|
|
809
|
-
f =
|
|
1149
|
+
f = new Decimal$1(fv);
|
|
810
1150
|
v = fv.length;
|
|
811
1151
|
}
|
|
812
|
-
const i =
|
|
1152
|
+
const i = new Decimal$1(iv).abs();
|
|
813
1153
|
let w;
|
|
814
1154
|
let t;
|
|
815
1155
|
if (!f.isZero()) {
|
|
816
1156
|
const ft = fv.replace(/0+$/, "");
|
|
817
1157
|
w = ft.length;
|
|
818
|
-
t =
|
|
1158
|
+
t = new Decimal$1(ft);
|
|
819
1159
|
} else {
|
|
820
1160
|
w = 0;
|
|
821
|
-
t = ZERO
|
|
1161
|
+
t = ZERO;
|
|
822
1162
|
}
|
|
823
1163
|
return {
|
|
824
1164
|
Number: n,
|
|
@@ -849,8 +1189,8 @@ function GetOperands(s, exponent = 0) {
|
|
|
849
1189
|
*/
|
|
850
1190
|
function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
851
1191
|
const internalSlots = getInternalSlots(pl);
|
|
852
|
-
invariant
|
|
853
|
-
invariant
|
|
1192
|
+
invariant(Type(internalSlots) === "Object", "pl has to be an object");
|
|
1193
|
+
invariant("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
|
|
854
1194
|
if (!n.isFinite()) return {
|
|
855
1195
|
formattedString: String(n),
|
|
856
1196
|
pluralCategory: "other"
|
|
@@ -858,11 +1198,19 @@ function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
858
1198
|
const { locale, type, notation } = internalSlots;
|
|
859
1199
|
const s = FormatNumericToString(internalSlots, n).formattedString;
|
|
860
1200
|
let exponent = 0;
|
|
861
|
-
if (notation === "compact"
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
1201
|
+
if (notation === "compact") {
|
|
1202
|
+
const patterns = internalSlots.compactExponents?.[internalSlots.compactDisplay || "short"];
|
|
1203
|
+
const integer = (s[0] === "-" ? s.slice(1) : s).split(".")[0];
|
|
1204
|
+
let first = 0;
|
|
1205
|
+
while (first < integer.length && integer[first] === "0") first++;
|
|
1206
|
+
const magnitude = integer.length - first - 1;
|
|
1207
|
+
let selectedMagnitude = -1;
|
|
1208
|
+
if (patterns) for (const key in patterns) {
|
|
1209
|
+
const threshold = Number(key);
|
|
1210
|
+
if (threshold <= magnitude && threshold > selectedMagnitude) {
|
|
1211
|
+
selectedMagnitude = threshold;
|
|
1212
|
+
exponent = patterns[threshold];
|
|
1213
|
+
}
|
|
866
1214
|
}
|
|
867
1215
|
}
|
|
868
1216
|
return {
|
|
@@ -892,7 +1240,9 @@ function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
892
1240
|
* It resolves the appropriate plural form for a range by determining the plural forms of both the
|
|
893
1241
|
* start and end values, then consulting locale-specific range data.
|
|
894
1242
|
*
|
|
1243
|
+
* ECMA-402 §17.5.4 ResolvePluralRange, steps 1–3.
|
|
895
1244
|
* Specification: https://tc39.es/ecma402/#sec-resolvepluralrange
|
|
1245
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/pluralrules.html#L356-L358
|
|
896
1246
|
*
|
|
897
1247
|
* @param pluralRules - An initialized PluralRules object
|
|
898
1248
|
* @param x - Mathematical value for the range start
|
|
@@ -900,10 +1250,10 @@ function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
900
1250
|
* @returns The plural category for the range (zero, one, two, few, many, or other)
|
|
901
1251
|
*/
|
|
902
1252
|
function ResolvePluralRange(pluralRules, x, y, { getInternalSlots, PluralRuleSelect, PluralRuleSelectRange }) {
|
|
903
|
-
if (
|
|
1253
|
+
if (x.isNaN() || y.isNaN()) throw new RangeError("selectRange requires start and end values not to be NaN");
|
|
904
1254
|
const internalSlots = getInternalSlots(pluralRules);
|
|
905
|
-
invariant
|
|
906
|
-
invariant
|
|
1255
|
+
invariant(Type(internalSlots) === "Object", "pluralRules has to be an object");
|
|
1256
|
+
invariant("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
|
|
907
1257
|
const xp = ResolvePluralInternal(pluralRules, x, {
|
|
908
1258
|
getInternalSlots,
|
|
909
1259
|
PluralRuleSelect
|
|
@@ -982,11 +1332,13 @@ var PluralRules = class PluralRules {
|
|
|
982
1332
|
}
|
|
983
1333
|
resolvedOptions() {
|
|
984
1334
|
validateInstance(this, "resolvedOptions");
|
|
985
|
-
const opts =
|
|
1335
|
+
const opts = {};
|
|
986
1336
|
const internalSlots = getInternalSlots(this);
|
|
987
1337
|
opts.locale = internalSlots.locale;
|
|
988
1338
|
opts.type = internalSlots.type;
|
|
989
1339
|
[
|
|
1340
|
+
"notation",
|
|
1341
|
+
"compactDisplay",
|
|
990
1342
|
"minimumIntegerDigits",
|
|
991
1343
|
"minimumFractionDigits",
|
|
992
1344
|
"maximumFractionDigits",
|
|
@@ -996,7 +1348,21 @@ var PluralRules = class PluralRules {
|
|
|
996
1348
|
const val = internalSlots[field];
|
|
997
1349
|
if (val !== void 0) opts[field] = val;
|
|
998
1350
|
});
|
|
999
|
-
|
|
1351
|
+
const categories = PluralRules.localeData[internalSlots.locale].categories[internalSlots.type];
|
|
1352
|
+
opts.pluralCategories = [
|
|
1353
|
+
"zero",
|
|
1354
|
+
"one",
|
|
1355
|
+
"two",
|
|
1356
|
+
"few",
|
|
1357
|
+
"many",
|
|
1358
|
+
"other"
|
|
1359
|
+
].filter((category) => categories.includes(category));
|
|
1360
|
+
for (const field of [
|
|
1361
|
+
"roundingIncrement",
|
|
1362
|
+
"roundingMode",
|
|
1363
|
+
"roundingPriority",
|
|
1364
|
+
"trailingZeroDisplay"
|
|
1365
|
+
]) opts[field] = internalSlots[field];
|
|
1000
1366
|
return opts;
|
|
1001
1367
|
}
|
|
1002
1368
|
select(val) {
|
|
@@ -1035,7 +1401,7 @@ var PluralRules = class PluralRules {
|
|
|
1035
1401
|
* pr.selectRange(BigInt(1), BigInt(2)); // "other"
|
|
1036
1402
|
*
|
|
1037
1403
|
* @throws {TypeError} If start or end is undefined
|
|
1038
|
-
* @throws {RangeError} If start or end
|
|
1404
|
+
* @throws {RangeError} If start or end converts to NaN
|
|
1039
1405
|
*
|
|
1040
1406
|
* @note Chrome's native implementation (as of early 2025) has a bug where it throws
|
|
1041
1407
|
* "Cannot convert a BigInt value to a number" when using BigInt arguments. This is
|
|
@@ -1060,8 +1426,7 @@ var PluralRules = class PluralRules {
|
|
|
1060
1426
|
}
|
|
1061
1427
|
static __addLocaleData(...data) {
|
|
1062
1428
|
for (const { data: d, locale } of data) {
|
|
1063
|
-
PluralRules.localeData
|
|
1064
|
-
PluralRules.availableLocales.add(locale);
|
|
1429
|
+
registerLocaleData(locale, d, PluralRules.localeData, PluralRules.availableLocales);
|
|
1065
1430
|
if (!PluralRules.__defaultLocale) PluralRules.__defaultLocale = locale;
|
|
1066
1431
|
}
|
|
1067
1432
|
}
|