@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/polyfill.js
CHANGED
|
@@ -1,5 +1,393 @@
|
|
|
1
1
|
import { LookupSupportedLocales, ResolveLocale, match } 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
|
}
|
|
@@ -259,7 +650,7 @@ function ensureIntl() {
|
|
|
259
650
|
});
|
|
260
651
|
return Intl;
|
|
261
652
|
}
|
|
262
|
-
function invariant
|
|
653
|
+
function invariant(condition, message, Err = Error) {
|
|
263
654
|
if (!condition) throw new Err(message);
|
|
264
655
|
}
|
|
265
656
|
memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
|
|
@@ -295,8 +686,8 @@ function SetNumberFormatDigitOptions(internalSlots, opts, mnfdDefault, mxfdDefau
|
|
|
295
686
|
let mxsd = opts.maximumSignificantDigits;
|
|
296
687
|
internalSlots.minimumIntegerDigits = mnid;
|
|
297
688
|
const roundingIncrement = GetNumberOption(opts, "roundingIncrement", 1, 5e3, 1);
|
|
298
|
-
invariant
|
|
299
|
-
Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}
|
|
689
|
+
invariant(VALID_ROUNDING_INCREMENTS.has(roundingIncrement), `Invalid rounding increment value: ${roundingIncrement}.
|
|
690
|
+
Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`, RangeError);
|
|
300
691
|
const roundingMode = GetOption(opts, "roundingMode", "string", [
|
|
301
692
|
"ceil",
|
|
302
693
|
"floor",
|
|
@@ -326,26 +717,30 @@ Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`);
|
|
|
326
717
|
needSd = hasSd;
|
|
327
718
|
if (hasSd || !hasFd && notation === "compact") needFd = false;
|
|
328
719
|
}
|
|
329
|
-
if (needSd)
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
720
|
+
if (needSd) {
|
|
721
|
+
if (hasSd) {
|
|
722
|
+
internalSlots.minimumSignificantDigits = DefaultNumberOption(mnsd, 1, 21, 1);
|
|
723
|
+
internalSlots.maximumSignificantDigits = DefaultNumberOption(mxsd, internalSlots.minimumSignificantDigits, 21, 21);
|
|
724
|
+
} else {
|
|
725
|
+
internalSlots.minimumSignificantDigits = 1;
|
|
726
|
+
internalSlots.maximumSignificantDigits = 21;
|
|
727
|
+
}
|
|
335
728
|
}
|
|
336
|
-
if (needFd)
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
729
|
+
if (needFd) {
|
|
730
|
+
if (hasFd) {
|
|
731
|
+
mnfd = DefaultNumberOption(mnfd, 0, 100, void 0);
|
|
732
|
+
mxfd = DefaultNumberOption(mxfd, 0, 100, void 0);
|
|
733
|
+
if (mnfd === void 0) {
|
|
734
|
+
invariant(mxfd !== void 0, "maximumFractionDigits must be defined");
|
|
735
|
+
mnfd = Math.min(mnfdDefault, mxfd);
|
|
736
|
+
} else if (mxfd === void 0) mxfd = Math.max(mxfdDefault, mnfd);
|
|
737
|
+
else if (mnfd > mxfd) throw new RangeError(`Invalid range, ${mnfd} > ${mxfd}`);
|
|
738
|
+
internalSlots.minimumFractionDigits = mnfd;
|
|
739
|
+
internalSlots.maximumFractionDigits = mxfd;
|
|
740
|
+
} else {
|
|
741
|
+
internalSlots.minimumFractionDigits = mnfdDefault;
|
|
742
|
+
internalSlots.maximumFractionDigits = mxfdDefault;
|
|
743
|
+
}
|
|
349
744
|
}
|
|
350
745
|
if (!needSd && !needFd) {
|
|
351
746
|
internalSlots.minimumFractionDigits = 0;
|
|
@@ -368,8 +763,8 @@ Valid values are ${Array.from(VALID_ROUNDING_INCREMENTS).join(", ")}.`);
|
|
|
368
763
|
internalSlots.roundingPriority = "auto";
|
|
369
764
|
}
|
|
370
765
|
if (roundingIncrement !== 1) {
|
|
371
|
-
invariant
|
|
372
|
-
invariant
|
|
766
|
+
invariant(internalSlots.roundingType === "fractionDigits", "Invalid roundingType", TypeError);
|
|
767
|
+
invariant(internalSlots.maximumFractionDigits === internalSlots.minimumFractionDigits, "With roundingIncrement > 1, maximumFractionDigits and minimumFractionDigits must be equal.", RangeError);
|
|
373
768
|
}
|
|
374
769
|
}
|
|
375
770
|
//#endregion
|
|
@@ -384,13 +779,19 @@ function InitializePluralRules(pl, locales, options, { availableLocales, relevan
|
|
|
384
779
|
const r = ResolveLocale(availableLocales, requestedLocales, opt, relevantExtensionKeys, localeData, getDefaultLocale);
|
|
385
780
|
internalSlots.locale = r.locale;
|
|
386
781
|
internalSlots.type = GetOption(opts, "type", "string", ["cardinal", "ordinal"], "cardinal");
|
|
387
|
-
const notation = GetOption(opts, "notation", "string", [
|
|
782
|
+
const notation = GetOption(opts, "notation", "string", [
|
|
783
|
+
"standard",
|
|
784
|
+
"scientific",
|
|
785
|
+
"engineering",
|
|
786
|
+
"compact"
|
|
787
|
+
], "standard");
|
|
388
788
|
internalSlots.notation = notation;
|
|
789
|
+
const compactDisplay = GetOption(opts, "compactDisplay", "string", ["short", "long"], "short");
|
|
389
790
|
if (notation === "compact") {
|
|
390
|
-
internalSlots.compactDisplay =
|
|
391
|
-
|
|
791
|
+
internalSlots.compactDisplay = compactDisplay;
|
|
792
|
+
internalSlots.compactExponents = localeData[r.dataLocale]?.compactExponents;
|
|
392
793
|
}
|
|
393
|
-
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3,
|
|
794
|
+
SetNumberFormatDigitOptions(internalSlots, opts, 0, 3, notation);
|
|
394
795
|
return pl;
|
|
395
796
|
}
|
|
396
797
|
//#endregion
|
|
@@ -409,62 +810,8 @@ function Type(x) {
|
|
|
409
810
|
if (typeof x === "bigint") return "BigInt";
|
|
410
811
|
}
|
|
411
812
|
//#endregion
|
|
412
|
-
//#region packages/ecma402-abstract/NumberFormat/decimal-cache.js
|
|
413
|
-
/**
|
|
414
|
-
* Cached function to compute powers of 10 for Decimal.js operations.
|
|
415
|
-
* This cache significantly reduces overhead in ComputeExponent and ToRawFixed
|
|
416
|
-
* by memoizing expensive Decimal.pow(10, n) calculations.
|
|
417
|
-
*
|
|
418
|
-
* Common exponents (e.g., -20 to 20) are used repeatedly in number formatting,
|
|
419
|
-
* so caching provides substantial performance benefits.
|
|
420
|
-
*
|
|
421
|
-
* @param exponent - Can be a number or Decimal. If Decimal, it will be converted to string for cache key.
|
|
422
|
-
*/
|
|
423
|
-
const getPowerOf10 = memoize((exponent) => {
|
|
424
|
-
return Decimal.pow(10, exponent);
|
|
425
|
-
});
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region packages/ecma402-abstract/NumberFormat/ComputeExponentForMagnitude.js
|
|
428
|
-
/**
|
|
429
|
-
* The abstract operation ComputeExponentForMagnitude computes an exponent by which to scale a
|
|
430
|
-
* number of the given magnitude (power of ten of the most significant digit) according to the
|
|
431
|
-
* locale and the desired notation (scientific, engineering, or compact).
|
|
432
|
-
*/
|
|
433
|
-
function ComputeExponentForMagnitude(internalSlots, magnitude) {
|
|
434
|
-
const { notation, dataLocaleData, numberingSystem } = internalSlots;
|
|
435
|
-
switch (notation) {
|
|
436
|
-
case "standard": return 0;
|
|
437
|
-
case "scientific": return magnitude.toNumber();
|
|
438
|
-
case "engineering": return magnitude.div(3).floor().times(3).toNumber();
|
|
439
|
-
default: {
|
|
440
|
-
invariant$1(notation === "compact", "Invalid notation");
|
|
441
|
-
const { compactDisplay, style, currencyDisplay } = internalSlots;
|
|
442
|
-
let thresholdMap;
|
|
443
|
-
if (style === "currency" && currencyDisplay !== "name") thresholdMap = (dataLocaleData.numbers.currency[numberingSystem] || dataLocaleData.numbers.currency[dataLocaleData.numbers.nu[0]]).short;
|
|
444
|
-
else {
|
|
445
|
-
const decimal = dataLocaleData.numbers.decimal[numberingSystem] || dataLocaleData.numbers.decimal[dataLocaleData.numbers.nu[0]];
|
|
446
|
-
thresholdMap = compactDisplay === "long" ? decimal.long : decimal.short;
|
|
447
|
-
}
|
|
448
|
-
if (!thresholdMap) return 0;
|
|
449
|
-
const num = getPowerOf10(magnitude).toString();
|
|
450
|
-
const thresholds = Object.keys(thresholdMap);
|
|
451
|
-
if (num < thresholds[0]) return 0;
|
|
452
|
-
if (num > thresholds[thresholds.length - 1]) {
|
|
453
|
-
const magnitudeKey = thresholds[thresholds.length - 1];
|
|
454
|
-
if (thresholdMap[magnitudeKey].other === "0") return 0;
|
|
455
|
-
return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
|
|
456
|
-
}
|
|
457
|
-
const i = thresholds.indexOf(num);
|
|
458
|
-
if (i === -1) return 0;
|
|
459
|
-
const magnitudeKey = thresholds[i];
|
|
460
|
-
if (thresholdMap[magnitudeKey].other === "0") return 0;
|
|
461
|
-
return magnitudeKey.length - thresholdMap[magnitudeKey].other.match(/0+/)[0].length;
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
//#endregion
|
|
466
813
|
//#region packages/ecma402-abstract/constants.js
|
|
467
|
-
const ZERO
|
|
814
|
+
const ZERO = new Decimal(0);
|
|
468
815
|
const NEGATIVE_ZERO = new Decimal(-0);
|
|
469
816
|
//#endregion
|
|
470
817
|
//#region packages/ecma402-abstract/NumberFormat/GetUnsignedRoundingMode.js
|
|
@@ -499,21 +846,36 @@ function GetUnsignedRoundingMode(roundingMode, isNegative) {
|
|
|
499
846
|
function ApplyUnsignedRoundingMode(x, r1, r2, unsignedRoundingMode) {
|
|
500
847
|
if (x.eq(r1) || r1.eq(r2)) return r1;
|
|
501
848
|
if (x.eq(r2)) return r2;
|
|
502
|
-
invariant
|
|
849
|
+
invariant(r1.lessThan(x) && x.lessThan(r2), `x should be between r1 and r2 but x=${x}, r1=${r1}, r2=${r2}`);
|
|
503
850
|
if (unsignedRoundingMode === "zero") return r1;
|
|
504
851
|
if (unsignedRoundingMode === "infinity") return r2;
|
|
505
852
|
const d1 = x.minus(r1);
|
|
506
853
|
const d2 = r2.minus(x);
|
|
507
854
|
if (d1.lessThan(d2)) return r1;
|
|
508
855
|
if (d2.lessThan(d1)) return r2;
|
|
509
|
-
invariant
|
|
856
|
+
invariant(d1.eq(d2), "d1 should be equal to d2");
|
|
510
857
|
if (unsignedRoundingMode === "half-zero") return r1;
|
|
511
858
|
if (unsignedRoundingMode === "half-infinity") return r2;
|
|
512
|
-
invariant
|
|
859
|
+
invariant(unsignedRoundingMode === "half-even", "unsignedRoundingMode should be half-even");
|
|
513
860
|
if (r1.div(r2.minus(r1)).mod(2).isZero()) return r1;
|
|
514
861
|
return r2;
|
|
515
862
|
}
|
|
516
863
|
//#endregion
|
|
864
|
+
//#region packages/ecma402-abstract/NumberFormat/decimal-cache.js
|
|
865
|
+
/**
|
|
866
|
+
* Cached function to compute powers of 10 for Decimal.js operations.
|
|
867
|
+
* This cache significantly reduces overhead in ComputeExponent and ToRawFixed
|
|
868
|
+
* by memoizing expensive Decimal.pow(10, n) calculations.
|
|
869
|
+
*
|
|
870
|
+
* Common exponents (e.g., -20 to 20) are used repeatedly in number formatting,
|
|
871
|
+
* so caching provides substantial performance benefits.
|
|
872
|
+
*
|
|
873
|
+
* @param exponent - Can be a number or Decimal. If Decimal, it will be converted to string for cache key.
|
|
874
|
+
*/
|
|
875
|
+
const getPowerOf10 = memoize((exponent) => {
|
|
876
|
+
return Decimal.pow(10, exponent);
|
|
877
|
+
});
|
|
878
|
+
//#endregion
|
|
517
879
|
//#region packages/ecma402-abstract/NumberFormat/ToRawFixed.js
|
|
518
880
|
function ToRawFixedFn(n, f) {
|
|
519
881
|
return n.times(getPowerOf10(-f));
|
|
@@ -671,7 +1033,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
671
1033
|
if (x.isZero()) {
|
|
672
1034
|
m = repeat("0", p);
|
|
673
1035
|
e = 0;
|
|
674
|
-
xFinal = ZERO
|
|
1036
|
+
xFinal = ZERO;
|
|
675
1037
|
} else {
|
|
676
1038
|
const { n1, e1, r1 } = findN1E1R1(x, p);
|
|
677
1039
|
const { n2, e2, r2 } = findN2E2R2(x, p);
|
|
@@ -696,7 +1058,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
696
1058
|
m = m.slice(0, e + 1) + "." + m.slice(m.length - (p - (e + 1)));
|
|
697
1059
|
int = e + 1;
|
|
698
1060
|
} else {
|
|
699
|
-
invariant
|
|
1061
|
+
invariant(e < 0, "e should be less than 0");
|
|
700
1062
|
m = "0." + repeat("0", -e - 1) + m;
|
|
701
1063
|
int = 1;
|
|
702
1064
|
}
|
|
@@ -712,7 +1074,7 @@ function ToRawPrecision(x, minPrecision, maxPrecision, unsignedRoundingMode) {
|
|
|
712
1074
|
formattedString: m,
|
|
713
1075
|
roundedNumber: xFinal,
|
|
714
1076
|
integerDigitsCount: int,
|
|
715
|
-
roundingMagnitude: e
|
|
1077
|
+
roundingMagnitude: e - p + 1
|
|
716
1078
|
};
|
|
717
1079
|
}
|
|
718
1080
|
//#endregion
|
|
@@ -725,9 +1087,9 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
725
1087
|
let sign;
|
|
726
1088
|
if (x.isZero() && x.isNegative()) {
|
|
727
1089
|
sign = "negative";
|
|
728
|
-
x = ZERO
|
|
1090
|
+
x = ZERO;
|
|
729
1091
|
} else {
|
|
730
|
-
invariant
|
|
1092
|
+
invariant(x.isFinite(), "NumberFormatDigitInternalSlots value is not finite");
|
|
731
1093
|
if (x.lessThan(0)) sign = "negative";
|
|
732
1094
|
else sign = "positive";
|
|
733
1095
|
if (sign === "negative") x = x.negated();
|
|
@@ -745,14 +1107,14 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
745
1107
|
default:
|
|
746
1108
|
let sResult = ToRawPrecision(x, intlObject.minimumSignificantDigits, intlObject.maximumSignificantDigits, unsignedRoundingMode);
|
|
747
1109
|
let fResult = ToRawFixed(x, intlObject.minimumFractionDigits, intlObject.maximumFractionDigits, intlObject.roundingIncrement, unsignedRoundingMode);
|
|
748
|
-
if (intlObject.roundingType === "morePrecision")
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
1110
|
+
if (intlObject.roundingType === "morePrecision") {
|
|
1111
|
+
if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = sResult;
|
|
1112
|
+
else result = fResult;
|
|
1113
|
+
} else {
|
|
1114
|
+
invariant(intlObject.roundingType === "lessPrecision", "Invalid roundingType");
|
|
752
1115
|
if (sResult.roundingMagnitude <= fResult.roundingMagnitude) result = fResult;
|
|
753
1116
|
else result = sResult;
|
|
754
1117
|
}
|
|
755
|
-
break;
|
|
756
1118
|
}
|
|
757
1119
|
x = result.roundedNumber;
|
|
758
1120
|
let string = result.formattedString;
|
|
@@ -763,44 +1125,22 @@ function FormatNumericToString(intlObject, _x) {
|
|
|
763
1125
|
const int = result.integerDigitsCount;
|
|
764
1126
|
const minInteger = intlObject.minimumIntegerDigits;
|
|
765
1127
|
if (int < minInteger) string = repeat("0", minInteger - int) + string;
|
|
766
|
-
if (sign === "negative")
|
|
767
|
-
|
|
1128
|
+
if (sign === "negative") {
|
|
1129
|
+
if (x.isZero()) x = NEGATIVE_ZERO;
|
|
1130
|
+
else x = x.negated();
|
|
1131
|
+
}
|
|
768
1132
|
return {
|
|
769
1133
|
roundedNumber: x,
|
|
770
1134
|
formattedString: string
|
|
771
1135
|
};
|
|
772
1136
|
}
|
|
773
1137
|
//#endregion
|
|
774
|
-
//#region packages/ecma262-abstract/ToNumber.js
|
|
775
|
-
const ZERO = new Decimal(0);
|
|
776
|
-
function invariant(condition, message, Err = Error) {
|
|
777
|
-
if (!condition) throw new Err(message);
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* https://tc39.es/ecma262/#sec-tonumber
|
|
781
|
-
*/
|
|
782
|
-
function ToNumber(arg) {
|
|
783
|
-
if (typeof arg === "number") return new Decimal(arg);
|
|
784
|
-
if (typeof arg === "bigint") return new Decimal(arg.toString());
|
|
785
|
-
invariant(typeof arg !== "symbol", "Symbol is not supported", TypeError);
|
|
786
|
-
if (arg === void 0) return new Decimal(NaN);
|
|
787
|
-
if (arg === null || arg === 0) return ZERO;
|
|
788
|
-
if (arg === true) return new Decimal(1);
|
|
789
|
-
if (typeof arg === "string") try {
|
|
790
|
-
return new Decimal(arg);
|
|
791
|
-
} catch {
|
|
792
|
-
return new Decimal(NaN);
|
|
793
|
-
}
|
|
794
|
-
invariant(typeof arg === "object", "object expected", TypeError);
|
|
795
|
-
let primValue = ToPrimitive(arg, "number");
|
|
796
|
-
invariant(typeof primValue !== "object", "object expected", TypeError);
|
|
797
|
-
return ToNumber(primValue);
|
|
798
|
-
}
|
|
799
|
-
//#endregion
|
|
800
1138
|
//#region packages/ecma402-abstract/PluralRules/GetOperands.js
|
|
801
1139
|
/**
|
|
802
|
-
*
|
|
803
|
-
*
|
|
1140
|
+
* CLDR operands for the implementation-defined PluralRuleSelect
|
|
1141
|
+
* ECMA-402 §17.5.1 PluralRuleSelect, decimalString parameter and return definition.
|
|
1142
|
+
* https://tc39.es/ecma402/#sec-pluralruleselect
|
|
1143
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/pluralrules.html#L285-L290
|
|
804
1144
|
*
|
|
805
1145
|
* Implementation: Extended to support compact exponent (c/e operands)
|
|
806
1146
|
*
|
|
@@ -808,34 +1148,34 @@ function ToNumber(arg) {
|
|
|
808
1148
|
* @param exponent Compact decimal exponent (c/e operand), defaults to 0
|
|
809
1149
|
*/
|
|
810
1150
|
function GetOperands(s, exponent = 0) {
|
|
811
|
-
invariant
|
|
812
|
-
const n =
|
|
813
|
-
invariant
|
|
1151
|
+
invariant(typeof s === "string", `GetOperands should have been called with a string`);
|
|
1152
|
+
const n = new Decimal$1(s);
|
|
1153
|
+
invariant(n.isFinite(), "n should be finite");
|
|
814
1154
|
let dp = s.indexOf(".");
|
|
815
1155
|
let iv;
|
|
816
1156
|
let f;
|
|
817
1157
|
let v;
|
|
818
1158
|
let fv = "";
|
|
819
1159
|
if (dp === -1) {
|
|
820
|
-
iv =
|
|
821
|
-
f = ZERO
|
|
1160
|
+
iv = s;
|
|
1161
|
+
f = ZERO;
|
|
822
1162
|
v = 0;
|
|
823
1163
|
} else {
|
|
824
1164
|
iv = s.slice(0, dp);
|
|
825
1165
|
fv = s.slice(dp, s.length);
|
|
826
|
-
f =
|
|
1166
|
+
f = new Decimal$1(fv);
|
|
827
1167
|
v = fv.length;
|
|
828
1168
|
}
|
|
829
|
-
const i =
|
|
1169
|
+
const i = new Decimal$1(iv).abs();
|
|
830
1170
|
let w;
|
|
831
1171
|
let t;
|
|
832
1172
|
if (!f.isZero()) {
|
|
833
1173
|
const ft = fv.replace(/0+$/, "");
|
|
834
1174
|
w = ft.length;
|
|
835
|
-
t =
|
|
1175
|
+
t = new Decimal$1(ft);
|
|
836
1176
|
} else {
|
|
837
1177
|
w = 0;
|
|
838
|
-
t = ZERO
|
|
1178
|
+
t = ZERO;
|
|
839
1179
|
}
|
|
840
1180
|
return {
|
|
841
1181
|
Number: n,
|
|
@@ -866,8 +1206,8 @@ function GetOperands(s, exponent = 0) {
|
|
|
866
1206
|
*/
|
|
867
1207
|
function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
868
1208
|
const internalSlots = getInternalSlots(pl);
|
|
869
|
-
invariant
|
|
870
|
-
invariant
|
|
1209
|
+
invariant(Type(internalSlots) === "Object", "pl has to be an object");
|
|
1210
|
+
invariant("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
|
|
871
1211
|
if (!n.isFinite()) return {
|
|
872
1212
|
formattedString: String(n),
|
|
873
1213
|
pluralCategory: "other"
|
|
@@ -875,11 +1215,19 @@ function ResolvePluralInternal(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
875
1215
|
const { locale, type, notation } = internalSlots;
|
|
876
1216
|
const s = FormatNumericToString(internalSlots, n).formattedString;
|
|
877
1217
|
let exponent = 0;
|
|
878
|
-
if (notation === "compact"
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
1218
|
+
if (notation === "compact") {
|
|
1219
|
+
const patterns = internalSlots.compactExponents?.[internalSlots.compactDisplay || "short"];
|
|
1220
|
+
const integer = (s[0] === "-" ? s.slice(1) : s).split(".")[0];
|
|
1221
|
+
let first = 0;
|
|
1222
|
+
while (first < integer.length && integer[first] === "0") first++;
|
|
1223
|
+
const magnitude = integer.length - first - 1;
|
|
1224
|
+
let selectedMagnitude = -1;
|
|
1225
|
+
if (patterns) for (const key in patterns) {
|
|
1226
|
+
const threshold = Number(key);
|
|
1227
|
+
if (threshold <= magnitude && threshold > selectedMagnitude) {
|
|
1228
|
+
selectedMagnitude = threshold;
|
|
1229
|
+
exponent = patterns[threshold];
|
|
1230
|
+
}
|
|
883
1231
|
}
|
|
884
1232
|
}
|
|
885
1233
|
return {
|
|
@@ -909,7 +1257,9 @@ function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
909
1257
|
* It resolves the appropriate plural form for a range by determining the plural forms of both the
|
|
910
1258
|
* start and end values, then consulting locale-specific range data.
|
|
911
1259
|
*
|
|
1260
|
+
* ECMA-402 §17.5.4 ResolvePluralRange, steps 1–3.
|
|
912
1261
|
* Specification: https://tc39.es/ecma402/#sec-resolvepluralrange
|
|
1262
|
+
* https://github.com/tc39/ecma402/blob/b1c961988b9a07894b1dc3dc2b5626ea48387d61/spec/pluralrules.html#L356-L358
|
|
913
1263
|
*
|
|
914
1264
|
* @param pluralRules - An initialized PluralRules object
|
|
915
1265
|
* @param x - Mathematical value for the range start
|
|
@@ -917,10 +1267,10 @@ function ResolvePlural(pl, n, { getInternalSlots, PluralRuleSelect }) {
|
|
|
917
1267
|
* @returns The plural category for the range (zero, one, two, few, many, or other)
|
|
918
1268
|
*/
|
|
919
1269
|
function ResolvePluralRange(pluralRules, x, y, { getInternalSlots, PluralRuleSelect, PluralRuleSelectRange }) {
|
|
920
|
-
if (
|
|
1270
|
+
if (x.isNaN() || y.isNaN()) throw new RangeError("selectRange requires start and end values not to be NaN");
|
|
921
1271
|
const internalSlots = getInternalSlots(pluralRules);
|
|
922
|
-
invariant
|
|
923
|
-
invariant
|
|
1272
|
+
invariant(Type(internalSlots) === "Object", "pluralRules has to be an object");
|
|
1273
|
+
invariant("initializedPluralRules" in internalSlots, "pluralrules must be initialized");
|
|
924
1274
|
const xp = ResolvePluralInternal(pluralRules, x, {
|
|
925
1275
|
getInternalSlots,
|
|
926
1276
|
PluralRuleSelect
|
|
@@ -999,11 +1349,13 @@ var PluralRules = class PluralRules {
|
|
|
999
1349
|
}
|
|
1000
1350
|
resolvedOptions() {
|
|
1001
1351
|
validateInstance(this, "resolvedOptions");
|
|
1002
|
-
const opts =
|
|
1352
|
+
const opts = {};
|
|
1003
1353
|
const internalSlots = getInternalSlots(this);
|
|
1004
1354
|
opts.locale = internalSlots.locale;
|
|
1005
1355
|
opts.type = internalSlots.type;
|
|
1006
1356
|
[
|
|
1357
|
+
"notation",
|
|
1358
|
+
"compactDisplay",
|
|
1007
1359
|
"minimumIntegerDigits",
|
|
1008
1360
|
"minimumFractionDigits",
|
|
1009
1361
|
"maximumFractionDigits",
|
|
@@ -1013,7 +1365,21 @@ var PluralRules = class PluralRules {
|
|
|
1013
1365
|
const val = internalSlots[field];
|
|
1014
1366
|
if (val !== void 0) opts[field] = val;
|
|
1015
1367
|
});
|
|
1016
|
-
|
|
1368
|
+
const categories = PluralRules.localeData[internalSlots.locale].categories[internalSlots.type];
|
|
1369
|
+
opts.pluralCategories = [
|
|
1370
|
+
"zero",
|
|
1371
|
+
"one",
|
|
1372
|
+
"two",
|
|
1373
|
+
"few",
|
|
1374
|
+
"many",
|
|
1375
|
+
"other"
|
|
1376
|
+
].filter((category) => categories.includes(category));
|
|
1377
|
+
for (const field of [
|
|
1378
|
+
"roundingIncrement",
|
|
1379
|
+
"roundingMode",
|
|
1380
|
+
"roundingPriority",
|
|
1381
|
+
"trailingZeroDisplay"
|
|
1382
|
+
]) opts[field] = internalSlots[field];
|
|
1017
1383
|
return opts;
|
|
1018
1384
|
}
|
|
1019
1385
|
select(val) {
|
|
@@ -1052,7 +1418,7 @@ var PluralRules = class PluralRules {
|
|
|
1052
1418
|
* pr.selectRange(BigInt(1), BigInt(2)); // "other"
|
|
1053
1419
|
*
|
|
1054
1420
|
* @throws {TypeError} If start or end is undefined
|
|
1055
|
-
* @throws {RangeError} If start or end
|
|
1421
|
+
* @throws {RangeError} If start or end converts to NaN
|
|
1056
1422
|
*
|
|
1057
1423
|
* @note Chrome's native implementation (as of early 2025) has a bug where it throws
|
|
1058
1424
|
* "Cannot convert a BigInt value to a number" when using BigInt arguments. This is
|
|
@@ -1077,8 +1443,7 @@ var PluralRules = class PluralRules {
|
|
|
1077
1443
|
}
|
|
1078
1444
|
static __addLocaleData(...data) {
|
|
1079
1445
|
for (const { data: d, locale } of data) {
|
|
1080
|
-
PluralRules.localeData
|
|
1081
|
-
PluralRules.availableLocales.add(locale);
|
|
1446
|
+
registerLocaleData(locale, d, PluralRules.localeData, PluralRules.availableLocales);
|
|
1082
1447
|
if (!PluralRules.__defaultLocale) PluralRules.__defaultLocale = locale;
|
|
1083
1448
|
}
|
|
1084
1449
|
}
|