@tolki/num 2.2.6 → 2.3.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/README.md CHANGED
@@ -66,7 +66,7 @@ export const words = /* @__PURE__ */ spell(5);
66
66
 
67
67
  esbuild doesn't follow the mark across files, so it needs the same comment on any helper call. [Bundling and Tree-Shaking](https://tolki.abe.dev/tree-shaking.html) covers every bundler.
68
68
 
69
- `useLocale` and `useCurrency` set the defaults that every formatter reads, and `withLocale` and `withCurrency` run a callback around a temporary swap of them, so a call to any of the four is always kept.
69
+ `useLocale` and `useCurrency` set the defaults that every formatter reads, and `withLocale` and `withCurrency` run a callback around a temporary swap of them. `normalizeLocalesUsing` sets how every formatter converts a locale. A call to any of the five is always kept.
70
70
 
71
71
  ## Tolki Number Utilities List
72
72
 
@@ -74,10 +74,12 @@ esbuild doesn't follow the mark across files, so it needs the same comment on an
74
74
 
75
75
  These are the number utilities that can be used independently as single functions.
76
76
 
77
- [abbreviate](#abbreviate) [clamp](#clamp) [currency](#currency) [defaultCurrency](#defaultcurrency) [defaultLocale](#defaultlocale) [fileSize](#filesize) [forHumans](#forhumans) [format](#format) [minutesToHuman](#minutestohuman) [ordinal](#ordinal) [pairs](#pairs) [parse](#parse) [parseFloat](#parsefloat) [parseInt](#parseint) [percentage](#percentage) [spell](#spell) [spellOrdinal](#spellordinal) [secondsToHuman](#secondstohuman) [trim](#trim) [useLocale](#uselocale) [withLocale](#withlocale) [useCurrency](#usecurrency) [withCurrency](#withcurrency)
77
+ [abbreviate](#abbreviate) [clamp](#clamp) [currency](#currency) [defaultCurrency](#defaultcurrency) [defaultLocale](#defaultlocale) [fileSize](#filesize) [forHumans](#forhumans) [format](#format) [minutesToHuman](#minutestohuman) [normalizeLocalesUsing](#normalizelocalesusing) [ordinal](#ordinal) [pairs](#pairs) [parse](#parse) [parseFloat](#parsefloat) [parseInt](#parseint) [percentage](#percentage) [spell](#spell) [spellOrdinal](#spellordinal) [secondsToHuman](#secondstohuman) [trim](#trim) [useLocale](#uselocale) [withLocale](#withlocale) [useCurrency](#usecurrency) [withCurrency](#withcurrency)
78
78
 
79
79
  ### Number Utilities Details
80
80
 
81
+ Every function that takes a locale reads Laravel's spelling (`pt_BR`) and BCP 47 (`pt-BR`) alike, as Laravel does through ICU. An empty locale means the runtime's own. A locale the runtime has no data for throws an `Error` with Laravel's message. [normalizeLocalesUsing](#normalizelocalesusing) changes how a locale is converted.
82
+
81
83
  #### abbreviate
82
84
 
83
85
  Convert the number to its human-readable equivalent.
@@ -234,6 +236,10 @@ const result3 = format(100000.123, null, 2);
234
236
  const result4 = format(100000, null, null, "de");
235
237
 
236
238
  // result4 is "100.000"
239
+
240
+ const result5 = format(1234.5, 2, null, "pt_BR");
241
+
242
+ // result5 is "1.234,50"
237
243
  ```
238
244
 
239
245
  #### minutesToHuman
@@ -252,10 +258,38 @@ const result2 = minutesToHuman(61, false);
252
258
  // result2 is "1 hour, 1 minute"
253
259
  ```
254
260
 
261
+ #### normalizeLocalesUsing
262
+
263
+ `normalizeLocalesUsing` permanently changes the module-wide conversion for every other example on this page, so it doesn't have a live playground here — trying it would silently change the output of every other widget below.
264
+
265
+ Set the callback that turns every locale into the tag `Intl` reads, or `null` to pass locales through unchanged. The default is `localeTag`, which accepts `pt_BR` and `pt-BR` alike. `@tolki/num` exports it, and `normalizeLocalesUsing(localeTag)` restores the default.
266
+
267
+ ```javascript
268
+ import { format, localeTag, normalizeLocalesUsing } from "@tolki/num";
269
+
270
+ const result = format(1234.5, 2, null, "pt_BR");
271
+
272
+ // result is "1.234,50"
273
+
274
+ // Map your own aliases, and keep the default for everything else.
275
+ normalizeLocalesUsing((locale) =>
276
+ locale === "br" ? "pt-BR" : localeTag(locale),
277
+ );
278
+
279
+ const result2 = format(1234.5, 2, null, "br");
280
+
281
+ // result2 is "1.234,50"
282
+
283
+ // Hand locales to Intl exactly as written. "pt_BR" now throws.
284
+ normalizeLocalesUsing(null);
285
+ ```
286
+
255
287
  #### ordinal
256
288
 
257
289
  Convert the given number to ordinal form.
258
290
 
291
+ It follows each locale's ordinal rules, as Laravel does, so German writes `1.` and Portuguese `1º`. A negative number is written with the minus sign (U+2212), not a hyphen, and a number of four or more digits is grouped.
292
+
259
293
  ```javascript
260
294
  import { ordinal } from "@tolki/num";
261
295
 
@@ -274,6 +308,26 @@ const result3 = ordinal(21);
274
308
  const result4 = ordinal(13);
275
309
 
276
310
  // result4 is "13th"
311
+
312
+ const result5 = ordinal(1, "pt_BR");
313
+
314
+ // result5 is "1º"
315
+
316
+ const result6 = ordinal(1, "de");
317
+
318
+ // result6 is "1."
319
+
320
+ const result7 = ordinal(21, "fr");
321
+
322
+ // result7 is "21e"
323
+
324
+ const result8 = ordinal(-1);
325
+
326
+ // result8 is "−1st"
327
+
328
+ const result9 = ordinal(1000);
329
+
330
+ // result9 is "1,000th"
277
331
  ```
278
332
 
279
333
  #### pairs
@@ -372,11 +426,11 @@ const result4 = percentage(10, 2, null, "de");
372
426
 
373
427
  `spell` and `spellOrdinal` return a `Promise<string>` and dynamically import a locale bundle on first use. The playground component above doesn't yet support async functions, so these two don't have a live example — see the code samples below instead.
374
428
 
375
- Spell out the given number in the given locale. Returns a `Promise<string>`.
429
+ Spell out the given number in the given locale. Returns a `Promise<string>`. When no locale is given, it uses the default locale (see [useLocale](#uselocale)).
376
430
 
377
431
  Uses the [`to-words`](https://www.npmjs.com/package/to-words) package. Locales are loaded dynamically on demand, so only the locale you request is bundled (~3KB gzip per locale instead of ~54KB for all 94 locales).
378
432
 
379
- Supports 94 locales via [`to-words`](https://www.npmjs.com/package/to-words). You can pass a full locale code (e.g., `"fr-FR"`, `"en-IN"`) or a bare language code (e.g., `"fr"`, `"en"`) which will resolve to a sensible default. Unsupported locales fall back to `"en-US"`.
433
+ Supports 94 locales via [`to-words`](https://www.npmjs.com/package/to-words). You can pass a full locale code (e.g., `"fr-FR"`, `"en-IN"`) or a bare language code (e.g., `"fr"`, `"en"`) which will resolve to a sensible default. A locale that the runtime has no data for throws an `Error` with Laravel's message, as Laravel does. A locale the runtime knows but `to-words` has no words for, such as Welsh (`cy`), is spelled in English.
380
434
 
381
435
  ```javascript
382
436
  import { spell } from "@tolki/num";
@@ -412,7 +466,7 @@ const result = await spell(15, null, null, 10);
412
466
 
413
467
  #### spellOrdinal
414
468
 
415
- Spell out the given number in the given locale in ordinal form. Returns a `Promise<string>`.
469
+ Spell out the given number in the given locale in ordinal form. Returns a `Promise<string>`. When no locale is given, it uses the default locale (see [useLocale](#uselocale)). A locale that the runtime has no data for throws an `Error`.
416
470
 
417
471
  Uses [`to-words`](https://www.npmjs.com/package/to-words) v5 native ordinal support. See the [spell](#spell) function for details on locale handling.
418
472
 
@@ -474,6 +528,10 @@ import { useLocale } from "@tolki/num";
474
528
  useLocale("fr");
475
529
 
476
530
  // The default locale is now set to French
531
+
532
+ useLocale("pt_BR");
533
+
534
+ // defaultLocale() returns "pt_BR", the spelling as given
477
535
  ```
478
536
 
479
537
  #### withLocale
@@ -488,6 +546,8 @@ withLocale("fr", () => {
488
546
  }); // "1 234,56"
489
547
  ```
490
548
 
549
+ `withLocale("pt_BR", …)` reads either spelling, and `defaultLocale()` inside the callback returns it as given.
550
+
491
551
  #### useCurrency
492
552
 
493
553
  Set the default currency. This should be used at the start of your application to set the desired currency globally.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './num';
2
- export * from './speller';
1
+ export * from './num.js';
2
+ export * from './speller/index.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { abbreviate as e, clamp as t, currency as n, defaultCurrency as r, defaultLocale as i, fileSize as a, forHumans as o, format as s, minutesToHuman as c, ordinal as l, pairs as u, parse as d, parseFloat as f, parseInt as p, percentage as m, secondsToHuman as h, summarize as g, trim as _, useCurrency as v, useLocale as y, withCurrency as b, withLocale as x } from "./num.js";
2
- import { spell as S, spellOrdinal as C } from "./speller/index.js";
3
- export { e as abbreviate, t as clamp, n as currency, r as defaultCurrency, i as defaultLocale, a as fileSize, o as forHumans, s as format, c as minutesToHuman, l as ordinal, u as pairs, d as parse, f as parseFloat, p as parseInt, m as percentage, h as secondsToHuman, S as spell, C as spellOrdinal, g as summarize, _ as trim, v as useCurrency, y as useLocale, b as withCurrency, x as withLocale };
1
+ import { abbreviate as e, clamp as t, currency as n, defaultCurrency as r, defaultLocale as i, fileSize as a, forHumans as o, format as s, localeTag as c, minutesToHuman as l, normalizeLocalesUsing as u, ordinal as d, pairs as f, parse as p, parseFloat as m, parseInt as h, percentage as g, secondsToHuman as _, summarize as v, trim as y, useCurrency as b, useLocale as x, withCurrency as S, withLocale as C } from "./num.js";
2
+ import { spell as w, spellOrdinal as T } from "./speller/index.js";
3
+ export { e as abbreviate, t as clamp, n as currency, r as defaultCurrency, i as defaultLocale, a as fileSize, o as forHumans, s as format, c as localeTag, l as minutesToHuman, u as normalizeLocalesUsing, d as ordinal, f as pairs, p as parse, m as parseFloat, h as parseInt, g as percentage, _ as secondsToHuman, w as spell, T as spellOrdinal, v as summarize, y as trim, b as useCurrency, x as useLocale, S as withCurrency, C as withLocale };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Turns a locale into the tag `Intl` reads.
3
+ */
4
+ export type LocaleNormalizer = (locale: string) => string;
5
+ /**
6
+ * Set the callback that turns every locale into the tag `Intl` reads, or null to pass locales through unchanged.
7
+ *
8
+ * @sideEffects state writes the module locale normalizer
9
+ *
10
+ * @param callback - Turns a locale into a BCP 47 tag.
11
+ */
12
+ export declare function setLocaleNormalizer(callback: LocaleNormalizer | null): void;
13
+ /**
14
+ * Resolve a locale to the canonical tag `Intl` formats with, as PHP's NumberFormatter reads it through ICU.
15
+ *
16
+ * @param locale - The locale as the caller wrote it.
17
+ * @returns The canonical tag, or the runtime's own locale when empty.
18
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
19
+ */
20
+ export declare function intlLocale(locale: string): string;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locale/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;AAO1D;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAE3E;AAED;;;;;;GAMG;AAEH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAqBjD"}
@@ -0,0 +1,19 @@
1
+ import { localeTag as e } from "@tolki/utils";
2
+ // src/locale/index.ts
3
+ var t = e;
4
+ function n(e) {
5
+ t = e;
6
+ }
7
+ /* @__NO_SIDE_EFFECTS__ */
8
+ function r(e) {
9
+ if (e === "") return new Intl.NumberFormat().resolvedOptions().locale;
10
+ let n = t === null ? e : t(e), r;
11
+ try {
12
+ r = Intl.NumberFormat.supportedLocalesOf(n)[0];
13
+ } catch {
14
+ r = void 0;
15
+ }
16
+ if (r === void 0) throw Error(`NumberFormatter::__construct(): Argument #1 ($locale) "${e}" is invalid`);
17
+ return r;
18
+ }
19
+ export { r as intlLocale, n as setLocaleNormalizer };
package/dist/num.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export { localeTag } from '@tolki/utils';
1
2
  /**
2
3
  * Convert the number to its human-readable equivalent.
3
4
  *
@@ -17,6 +18,7 @@ export declare function abbreviate(number: number, precision?: number, maxPrecis
17
18
  * @param maxPrecision - The maximum number of decimal places to use.
18
19
  * @param locale - The locale to use for formatting.
19
20
  * @returns The formatted number string.
21
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
20
22
  *
21
23
  * @see https://tolki.abe.dev/numbers/number-utilities-list.html#format
22
24
  */
@@ -27,6 +29,7 @@ export declare function format(number: number, precision?: number | null, maxPre
27
29
  * @param value - The string to parse.
28
30
  * @param locale - The locale to use for parsing.
29
31
  * @returns The parsed number.
32
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
30
33
  *
31
34
  * @example
32
35
  *
@@ -39,6 +42,7 @@ export declare function parse(value: string, locale?: string | null): number;
39
42
  * @param value - The string to parse.
40
43
  * @param locale - The locale to use for parsing.
41
44
  * @returns The parsed integer or false if parsing fails.
45
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
42
46
  *
43
47
  * @see https://tolki.abe.dev/numbers/number-utilities-list.html#parseint
44
48
  */
@@ -49,6 +53,7 @@ export declare function parseInt(value: string, locale?: string | null): number
49
53
  * @param value - The string to parse.
50
54
  * @param locale - The locale to use for parsing.
51
55
  * @returns The parsed float or false if parsing fails.
56
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
52
57
  *
53
58
  * @see https://tolki.abe.dev/numbers/number-utilities-list.html#parsefloat
54
59
  */
@@ -57,8 +62,9 @@ export declare function parseFloat(value: string, locale?: string | null): numbe
57
62
  * Convert the given number to ordinal form.
58
63
  *
59
64
  * @param value - The number to convert.
60
- * @param locale - The locale to use for determining ordinal rules.
65
+ * @param locale - The locale whose ordinal rules to use.
61
66
  * @returns The number in ordinal form.
67
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
62
68
  *
63
69
  * @see https://tolki.abe.dev/numbers/number-utilities-list.html#ordinal
64
70
  */
@@ -71,6 +77,7 @@ export declare function ordinal(value: number, locale?: string | null): string;
71
77
  * @param maxPrecision - The maximum number of decimal places to use.
72
78
  * @param locale - The locale to use for formatting.
73
79
  * @returns The formatted percentage string.
80
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
74
81
  *
75
82
  * @see https://tolki.abe.dev/numbers/number-utilities-list.html#percentage
76
83
  */
@@ -83,6 +90,7 @@ export declare function percentage(number: number | string, precision?: number,
83
90
  * @param locale - The locale to use for formatting.
84
91
  * @param precision - The number of decimal places to use.
85
92
  * @returns The formatted currency string.
93
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
86
94
  *
87
95
  * @see https://tolki.abe.dev/numbers/number-utilities-list.html#currency
88
96
  */
@@ -239,4 +247,15 @@ export declare function defaultLocale(): string;
239
247
  * @see https://tolki.abe.dev/numbers/number-utilities-list.html#defaultcurrency
240
248
  */
241
249
  export declare function defaultCurrency(): string;
250
+ /**
251
+ * Set the callback that turns every locale into the tag `Intl` reads, or null to pass locales through unchanged.
252
+ *
253
+ * @sideEffects state writes the module locale normalizer
254
+ *
255
+ * @param callback - Turns a locale into a BCP 47 tag; `localeTag` by default
256
+ * @returns void
257
+ *
258
+ * @see https://tolki.abe.dev/numbers/number-utilities-list.html#normalizelocalesusing
259
+ */
260
+ export declare function normalizeLocalesUsing(callback: ((locale: string) => string) | null): void;
242
261
  //# sourceMappingURL=num.d.ts.map
package/dist/num.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"num.d.ts","sourceRoot":"","sources":["../src/num.ts"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AAEH,wBAAgB,UAAU,CACtB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAAU,EACrB,YAAY,GAAE,MAAM,GAAG,IAAW,GACnC,MAAM,GAAG,KAAK,CAEhB;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,MAAM,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,MAAM,GAAG,IAAW,EAC/B,YAAY,GAAE,MAAM,GAAG,IAAW,EAClC,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAA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C,MAAM,EAAE,MAAM,CAAC,EAAE,CA6BpB;AAED;;;;;;;GAOG;AAEH,wBAAgB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED;;;;;;;;GAQG;AAEH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,KAAK,GAAE,OAAc,GACtB,MAAM,CAIR;AAED;;;;;;;;GAQG;AAEH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,KAAK,GAAE,OAAc,GACtB,MAAM,CAoDR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,OAAO,GACxB,OAAO,GAAG,IAAI,CAUhB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAChC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,OAAO,GACxB,OAAO,GAAG,IAAI,CAUhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAElD;AAED;;;;;;GAMG;AAEH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;GAMG;AAEH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,GAC9C,IAAI,CAEN"}
package/dist/num.js CHANGED
@@ -1,99 +1,81 @@
1
- import { InvalidArgumentException as e } from "@tolki/utils";
1
+ import { intlLocale as e, setLocaleNormalizer as t } from "./locale/index.js";
2
+ import { formatOrdinal as n } from "./ordinal/index.js";
3
+ import { InvalidArgumentException as r, localeTag as i } from "@tolki/utils";
2
4
  // src/num.ts
3
- var t = "en", n = "USD";
5
+ var a = "en", o = "USD";
4
6
  /* @__NO_SIDE_EFFECTS__ */
5
- function r(e, t = 0, n = null) {
6
- return /* @__PURE__ */ f(e, t, n, !0);
7
+ function s(e, t = 0, n = null) {
8
+ return /* @__PURE__ */ g(e, t, n, !0);
7
9
  }
8
10
  /* @__NO_SIDE_EFFECTS__ */
9
- function i(e, n = null, r = null, i = null) {
10
- i ??= t;
11
- let a = {
11
+ function c(t, n = null, r = null, i = null) {
12
+ let o = /* @__PURE__ */ e(i ?? a), s = {
12
13
  style: "decimal",
13
14
  useGrouping: !0
14
15
  };
15
- r == null ? n != null && (a.minimumFractionDigits = n, a.maximumFractionDigits = n) : (a.maximumFractionDigits = r, a.minimumFractionDigits = 0);
16
- let o = new Intl.NumberFormat(i, a);
17
- return o.format(T(e, o.format));
16
+ r == null ? n != null && (s.minimumFractionDigits = n, s.maximumFractionDigits = n) : (s.maximumFractionDigits = r, s.minimumFractionDigits = 0);
17
+ let c = new Intl.NumberFormat(o, s);
18
+ return c.format(A(t, c.format));
18
19
  }
19
20
  /* @__NO_SIDE_EFFECTS__ */
20
- function a(e, n = null) {
21
- n ??= t;
22
- let r = new Intl.NumberFormat(n).formatToParts(12345.6), i = /* @__PURE__ */ new Set(), a = ".";
23
- for (let e of r) e.type === "group" ? i.add(e.value) : e.type === "decimal" && (a = e.value);
21
+ function l(t, n = null) {
22
+ let r = /* @__PURE__ */ e(n ?? a), i = new Intl.NumberFormat(r).formatToParts(12345.6), o = /* @__PURE__ */ new Set(), s = ".";
23
+ for (let e of i) e.type === "group" ? o.add(e.value) : e.type === "decimal" && (s = e.value);
24
24
  for (let e of [
25
25
  "\xA0",
26
26
  " ",
27
27
  " "
28
- ]) i.add(e);
29
- let o = e;
30
- for (let e of i) {
28
+ ]) o.add(e);
29
+ let c = t;
30
+ for (let e of o) {
31
31
  let t = new RegExp(e.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), "g");
32
- o = o.replace(t, "");
32
+ c = c.replace(t, "");
33
33
  }
34
- if (a !== ".") {
35
- let e = new RegExp(a.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), t = o.lastIndexOf(a);
36
- t !== -1 && (o = o.slice(0, t).replace(e, "") + "." + o.slice(t + a.length));
34
+ if (s !== ".") {
35
+ let e = new RegExp(s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), t = c.lastIndexOf(s);
36
+ t !== -1 && (c = c.slice(0, t).replace(e, "") + "." + c.slice(t + s.length));
37
37
  }
38
- return o = o.replace(/[\s\u00A0\u202F\u2009]+/g, "").trim(), globalThis.Number(o);
38
+ return c = c.replace(/[\s\u00A0\u202F\u2009]+/g, "").trim(), globalThis.Number(c);
39
39
  }
40
40
  /* @__NO_SIDE_EFFECTS__ */
41
- function o(e, t = null) {
42
- let n = /* @__PURE__ */ a(e, t);
41
+ function u(e, t = null) {
42
+ let n = /* @__PURE__ */ l(e, t);
43
43
  return Number.isNaN(n) ? !1 : n < 0 ? Math.ceil(n) : Math.floor(n);
44
44
  }
45
45
  /* @__NO_SIDE_EFFECTS__ */
46
- function s(e, t = null) {
47
- return /* @__PURE__ */ a(e, t);
46
+ function d(e, t = null) {
47
+ return /* @__PURE__ */ l(e, t);
48
48
  }
49
49
  /* @__NO_SIDE_EFFECTS__ */
50
- function c(e, n = null) {
51
- let r = n ?? t;
52
- try {
53
- let t = new Intl.PluralRules(r, { type: "ordinal" }).select(e), n = String(r.split("-")[0]), i = {
54
- one: "st",
55
- two: "nd",
56
- few: "rd",
57
- other: "th"
58
- }, a = { en: i }[n] ?? i;
59
- return `${e}${a[t] ?? a.other}`;
60
- } catch {
61
- let t = Math.abs(e), n = t % 100;
62
- if (n >= 11 && n <= 13) return `${e}th`;
63
- switch (t % 10) {
64
- case 1: return `${e}st`;
65
- case 2: return `${e}nd`;
66
- case 3: return `${e}rd`;
67
- default: return `${e}th`;
68
- }
69
- }
50
+ function f(t, r = null) {
51
+ return /* @__PURE__ */ n(t, /* @__PURE__ */ e(r ?? a));
70
52
  }
71
53
  /* @__NO_SIDE_EFFECTS__ */
72
- function l(e, n = 0, r = null, i = null) {
73
- let o = i ?? t, s = typeof e == "string" ? /* @__PURE__ */ a(e, o) : e, c = {
54
+ function p(t, n = 0, r = null, i = null) {
55
+ let o = i ?? a, s = typeof t == "string" ? /* @__PURE__ */ l(t, o) : t, c = /* @__PURE__ */ e(o), u = {
74
56
  style: "percent",
75
57
  useGrouping: !0
76
58
  };
77
- r == null ? (c.minimumFractionDigits = n, c.maximumFractionDigits = n) : (c.maximumFractionDigits = r, c.minimumFractionDigits = 0);
78
- let l = new Intl.NumberFormat(o, c);
79
- return l.format(T(s / 100, l.format));
59
+ r == null ? (u.minimumFractionDigits = n, u.maximumFractionDigits = n) : (u.maximumFractionDigits = r, u.minimumFractionDigits = 0);
60
+ let d = new Intl.NumberFormat(c, u);
61
+ return d.format(A(s / 100, d.format));
80
62
  }
81
63
  /* @__NO_SIDE_EFFECTS__ */
82
- function u(e, r = "", i = null, o = null) {
83
- let s = i ?? t, c = typeof e == "string" ? /* @__PURE__ */ a(e, s) : e, l = {
64
+ function m(t, n = "", r = null, i = null) {
65
+ let s = r ?? a, c = typeof t == "string" ? /* @__PURE__ */ l(t, s) : t, u = /* @__PURE__ */ e(s), d = {
84
66
  style: "currency",
85
- currency: r && r.length ? r : n,
67
+ currency: n && n.length ? n : o,
86
68
  useGrouping: !0
87
69
  };
88
- o != null && (l.minimumFractionDigits = o, l.maximumFractionDigits = o);
89
- let u = new Intl.NumberFormat(s, l);
90
- return u.format(T(c, u.format));
70
+ i != null && (d.minimumFractionDigits = i, d.maximumFractionDigits = i);
71
+ let f = new Intl.NumberFormat(u, d);
72
+ return f.format(A(c, f.format));
91
73
  }
92
74
  /* @__NO_SIDE_EFFECTS__ */
93
- function d(e, t = 0, n = null) {
75
+ function h(e, t = 0, n = null) {
94
76
  let r = typeof e == "string" ? Number(e) : e;
95
- if (!Number.isFinite(r)) return `${/* @__PURE__ */ i(r, t, n)} B`;
96
- let a = [
77
+ if (!Number.isFinite(r)) return `${/* @__PURE__ */ c(r, t, n)} B`;
78
+ let i = [
97
79
  "B",
98
80
  "KB",
99
81
  "MB",
@@ -103,13 +85,13 @@ function d(e, t = 0, n = null) {
103
85
  "EB",
104
86
  "ZB",
105
87
  "YB"
106
- ], o = a.length, s = 0;
107
- for (; Math.abs(r) / 1024 > .9 && s < o - 1;) r /= 1024, s++;
108
- return `${/* @__PURE__ */ i(r, t, n)} ${a[s]}`;
88
+ ], a = i.length, o = 0;
89
+ for (; Math.abs(r) / 1024 > .9 && o < a - 1;) r /= 1024, o++;
90
+ return `${/* @__PURE__ */ c(r, t, n)} ${i[o]}`;
109
91
  }
110
92
  /* @__NO_SIDE_EFFECTS__ */
111
- function f(e, t = 0, n = null, r = !1) {
112
- return /* @__PURE__ */ p(e, t, n, r ? {} : {
93
+ function g(e, t = 0, n = null, r = !1) {
94
+ return /* @__PURE__ */ _(e, t, n, r ? {} : {
113
95
  3: " thousand",
114
96
  6: " million",
115
97
  9: " billion",
@@ -118,58 +100,58 @@ function f(e, t = 0, n = null, r = !1) {
118
100
  });
119
101
  }
120
102
  /* @__NO_SIDE_EFFECTS__ */
121
- function p(e, t = 0, n = null, r = {}) {
122
- if (!Number.isFinite(e)) return /* @__PURE__ */ i(e, t, n);
103
+ function _(e, t = 0, n = null, r = {}) {
104
+ if (!Number.isFinite(e)) return /* @__PURE__ */ c(e, t, n);
123
105
  if (Object.keys(r).length === 0 && (r = {
124
106
  3: "K",
125
107
  6: "M",
126
108
  9: "B",
127
109
  12: "T",
128
110
  15: "Q"
129
- }), Number(e) === 0) return t > 0 ? /* @__PURE__ */ i(0, t, n) : "0";
111
+ }), Number(e) === 0) return t > 0 ? /* @__PURE__ */ c(0, t, n) : "0";
130
112
  if (e < 0) {
131
- let i = /* @__PURE__ */ p(Math.abs(e), t, n, r);
132
- return i === /* @__PURE__ */ p(0, t, n, r) ? i : `-${i}`;
113
+ let i = /* @__PURE__ */ _(Math.abs(e), t, n, r);
114
+ return i === /* @__PURE__ */ _(0, t, n, r) ? i : `-${i}`;
133
115
  }
134
116
  if (e >= 0x38d7ea4c68000) {
135
117
  let i = Object.keys(r).map((e) => Number(e)).filter((e) => !Number.isNaN(e)).sort((e, t) => e - t), a = i[i.length - 1], o = r[a];
136
- return `${/* @__PURE__ */ p(e / 0x38d7ea4c68000, t, n, r)}${o}`.trim();
118
+ return `${/* @__PURE__ */ _(e / 0x38d7ea4c68000, t, n, r)}${o}`.trim();
137
119
  }
138
- let o = Math.floor(Math.log10(e)), s = Math.max(0, o - o % 3), c = e / 10 ** s, l;
139
- if (l = n == null ? t > 0 ? /* @__PURE__ */ i(c, t, null) : s === 3 && c < 10 && Math.abs(e) % 10 == 0 ? /* @__PURE__ */ i(c, null, 1) : /* @__PURE__ */ i(c, 0, null) : /* @__PURE__ */ i(c, null, n), /* @__PURE__ */ a(l) >= 1e3 && r[s + 3] !== void 0) {
140
- s += 3;
141
- let e = c / 1e3;
142
- l = n == null ? t > 0 ? /* @__PURE__ */ i(e, t, null) : /* @__PURE__ */ i(e, 0, null) : /* @__PURE__ */ i(e, null, n);
120
+ let i = Math.floor(Math.log10(e)), a = Math.max(0, i - i % 3), o = e / 10 ** a, s;
121
+ if (s = n == null ? t > 0 ? /* @__PURE__ */ c(o, t, null) : a === 3 && o < 10 && Math.abs(e) % 10 == 0 ? /* @__PURE__ */ c(o, null, 1) : /* @__PURE__ */ c(o, 0, null) : /* @__PURE__ */ c(o, null, n), /* @__PURE__ */ l(s) >= 1e3 && r[a + 3] !== void 0) {
122
+ a += 3;
123
+ let e = o / 1e3;
124
+ s = n == null ? t > 0 ? /* @__PURE__ */ c(e, t, null) : /* @__PURE__ */ c(e, 0, null) : /* @__PURE__ */ c(e, null, n);
143
125
  }
144
- let u = r[s] ?? "";
145
- return `${l}${u}`.trim();
126
+ let u = r[a] ?? "";
127
+ return `${s}${u}`.trim();
146
128
  }
147
129
  /* @__NO_SIDE_EFFECTS__ */
148
- function m(e, t, n) {
130
+ function v(e, t, n) {
149
131
  return Math.min(Math.max(e, t), n);
150
132
  }
151
133
  /* @__NO_SIDE_EFFECTS__ */
152
- function h(t, n, r = 0, i = 1) {
153
- if (n === 0) throw new e("The $by argument must not be zero.");
154
- n = Math.abs(n);
155
- let a = [], o = r;
156
- for (; o < t; o += n) {
157
- let e = o + n - i;
158
- e > t && (e = t), a.push([o, e]);
134
+ function y(e, t, n = 0, i = 1) {
135
+ if (t === 0) throw new r("The $by argument must not be zero.");
136
+ t = Math.abs(t);
137
+ let a = [], o = n;
138
+ for (; o < e; o += t) {
139
+ let n = o + t - i;
140
+ n > e && (n = e), a.push([o, n]);
159
141
  }
160
142
  let s = a.at(-1);
161
- return s !== void 0 && o === t && s[1] < t && a.push([o, t]), a;
143
+ return s !== void 0 && o === e && s[1] < e && a.push([o, e]), a;
162
144
  }
163
145
  /* @__NO_SIDE_EFFECTS__ */
164
- function g(e) {
146
+ function b(e) {
165
147
  return isFinite(e) ? JSON.parse(JSON.stringify(e)) : e;
166
148
  }
167
149
  /* @__NO_SIDE_EFFECTS__ */
168
- function _(e, t = !0) {
169
- return /* @__PURE__ */ v(Number(e) * 60, t);
150
+ function x(e, t = !0) {
151
+ return /* @__PURE__ */ S(Number(e) * 60, t);
170
152
  }
171
153
  /* @__NO_SIDE_EFFECTS__ */
172
- function v(e, t = !0) {
154
+ function S(e, t = !0) {
173
155
  let n = Number(e);
174
156
  if ((!Number.isFinite(n) || n < 0) && (n = 0), n === 0) return "0 seconds";
175
157
  let r = 3600, i = 24 * r, a = 7 * i, o = 4 * a, s = [
@@ -195,39 +177,42 @@ function v(e, t = !0) {
195
177
  }
196
178
  return l.join(", ");
197
179
  }
198
- function y(e, n) {
199
- let r = t;
200
- x(e);
180
+ function C(e, t) {
181
+ let n = a;
182
+ T(e);
201
183
  try {
202
- return n();
184
+ return t();
203
185
  } finally {
204
- x(r);
186
+ T(n);
205
187
  }
206
188
  }
207
- function b(e, t) {
208
- let r = n;
209
- S(e);
189
+ function w(e, t) {
190
+ let n = o;
191
+ E(e);
210
192
  try {
211
193
  return t();
212
194
  } finally {
213
- S(r);
195
+ E(n);
214
196
  }
215
197
  }
216
- function x(e) {
217
- t = e;
198
+ function T(e) {
199
+ a = e;
218
200
  }
219
- function S(e) {
220
- n = e;
201
+ function E(e) {
202
+ o = e;
221
203
  }
222
204
  /* @__NO_SIDE_EFFECTS__ */
223
- function C() {
224
- return t;
205
+ function D() {
206
+ return a;
225
207
  }
226
208
  /* @__NO_SIDE_EFFECTS__ */
227
- function w() {
228
- return n;
209
+ function O() {
210
+ return o;
211
+ }
212
+ function k(e) {
213
+ t(e);
229
214
  }
230
- function T(e, t) {
215
+ function A(e, t) {
231
216
  return e === 0 || e < 0 && t(Math.abs(e)) === t(0) ? 0 : e;
232
217
  }
233
- export { r as abbreviate, m as clamp, u as currency, w as defaultCurrency, C as defaultLocale, d as fileSize, f as forHumans, i as format, _ as minutesToHuman, c as ordinal, h as pairs, a as parse, s as parseFloat, o as parseInt, l as percentage, v as secondsToHuman, p as summarize, g as trim, S as useCurrency, x as useLocale, b as withCurrency, y as withLocale };
218
+ export { s as abbreviate, v as clamp, m as currency, O as defaultCurrency, D as defaultLocale, h as fileSize, g as forHumans, c as format, i as localeTag, x as minutesToHuman, k as normalizeLocalesUsing, f as ordinal, y as pairs, l as parse, d as parseFloat, u as parseInt, p as percentage, S as secondsToHuman, _ as summarize, b as trim, E as useCurrency, T as useLocale, w as withCurrency, C as withLocale };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Convert a number to ordinal form the way PHP's `NumberFormatter::ORDINAL` does for a locale.
3
+ *
4
+ * @param value - The number to convert.
5
+ * @param tag - A canonical BCP 47 tag the runtime supports.
6
+ * @returns The ordinal, such as `1st`, `1º` or `第1`.
7
+ */
8
+ export declare function formatOrdinal(value: number, tag: string): string;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ordinal/index.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAQhE"}
@@ -0,0 +1,56 @@
1
+ import { INDICATORS as e, ordinalRule as t } from "./rules.js";
2
+ import { isInteger as n, isString as r, isUndefined as i } from "@tolki/utils";
3
+ // src/ordinal/index.ts
4
+ var a = "−", o = 2147483647;
5
+ /* @__NO_SIDE_EFFECTS__ */
6
+ function s(e, n) {
7
+ let r = /* @__PURE__ */ t(n);
8
+ return c(r.indirect === !0 && Object.is(e, -0) ? 0 : e, n, r);
9
+ }
10
+ function c(e, t, r) {
11
+ if (Number.isNaN(e) || e === Infinity) return new Intl.NumberFormat(t).format(e);
12
+ if (e === -Infinity) {
13
+ let e = new Intl.NumberFormat(t).format(Infinity);
14
+ return r.indirect === !0 ? e : `${r.negative ?? a}${e}`;
15
+ }
16
+ if (e < 0) return i(r.negative) ? `${a}${c(-e, t, r)}` : `${r.negative}${p(-e, t, r, 0)}`;
17
+ if (r.fraction === !0 && !n(e)) return p(e, t, r, 1);
18
+ let o = r.whole?.[h(e)];
19
+ return i(o) ? `${r.prefix ?? ""}${p(e, t, r, 0)}${l(r.suffix, e, t)}` : o;
20
+ }
21
+ function l(e, t, n) {
22
+ return i(e) ? "" : r(e) ? e : "plural" in e ? e.plural[d(t, n)] ?? e.plural.other : u(e.indicator, t);
23
+ }
24
+ function u(t, n) {
25
+ let i = e[t], a = n;
26
+ for (;;) {
27
+ let t = h(a), [n, o] = i.findLast(([e]) => e <= t);
28
+ if (r(o)) return o;
29
+ let s = 10 ** Math.floor(Math.log10(n)), c = e[o.remainder];
30
+ a = a < s && c === i ? t % s : a % s, i = c;
31
+ }
32
+ }
33
+ function d(e, t) {
34
+ return Intl.PluralRules.supportedLocalesOf(t).length === 0 ? "other" : new Intl.PluralRules(t, { type: "ordinal" }).select(f(e));
35
+ }
36
+ function f(e) {
37
+ return e < 1 ? h(e) : n(e) ? e | 0 : Math.min(Math.trunc(e), o);
38
+ }
39
+ function p(e, t, n, r) {
40
+ let i = new Intl.NumberFormat(t, {
41
+ useGrouping: !1,
42
+ minimumFractionDigits: r,
43
+ maximumFractionDigits: r,
44
+ roundingMode: "halfEven"
45
+ }).formatToParts(e), a = new Intl.NumberFormat(t, { useGrouping: "always" }).formatToParts(1234567).find((e) => e.type === "group").value;
46
+ return i.map((e) => e.type === "integer" ? m(e.value, a, n.indian === !0) : e.value).join("");
47
+ }
48
+ function m(e, t, n) {
49
+ let r = Array.from(e), i = [], a = 3;
50
+ for (; r.length > a;) i.unshift(r.splice(-a).join("")), a = n ? 2 : 3;
51
+ return i.unshift(r.join("")), i.join(t);
52
+ }
53
+ function h(e) {
54
+ return Math.floor(e + .5);
55
+ }
56
+ export { s as formatOrdinal };
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The text an ordinal rule writes beside the number: a string as is, or picked by its plural category or its value.
3
+ */
4
+ export type OrdinalText = string | {
5
+ readonly plural: OrdinalPlural;
6
+ } | {
7
+ readonly indicator: IndicatorName;
8
+ };
9
+ /**
10
+ * The text for each ordinal plural category, as ICU's `$(ordinal,…)$` holds it.
11
+ */
12
+ export type OrdinalPlural = Readonly<Partial<Record<Intl.LDMLPluralRule, string>>> & {
13
+ readonly other: string;
14
+ };
15
+ /**
16
+ * The name of an RBNF indicator rule set.
17
+ */
18
+ export type IndicatorName = "af" | "bg" | "bg-larger" | "ee";
19
+ /**
20
+ * One rule of an indicator set: from `base` up, its text, or the set that reads the remainder by its power of ten.
21
+ */
22
+ export type IndicatorRule = readonly [
23
+ base: number,
24
+ text: string | {
25
+ readonly remainder: IndicatorName;
26
+ }
27
+ ];
28
+ /**
29
+ * ICU's default `%digits-ordinal` rule set for a locale, as the parts this port writes.
30
+ */
31
+ export interface OrdinalRule {
32
+ /** The text before the number. */
33
+ readonly prefix?: string;
34
+ /** The text after the number. */
35
+ readonly suffix?: OrdinalText;
36
+ /** The whole ordinal for a value that rounds to the key, as `ms` writes `No. 1`. */
37
+ readonly whole?: Readonly<Record<number, string>>;
38
+ /** Group digits in twos above the thousands, as `#,##,##0` does. */
39
+ readonly indian?: true;
40
+ /** Write a fraction with one decimal and no ordinal text, as an `x.x` rule does. */
41
+ readonly fraction?: true;
42
+ /** The text before a negative number written without its ordinal text; without it, U+2212 precedes the ordinal. */
43
+ readonly negative?: string;
44
+ /** The default rule hands the value to another rule set, which drops the sign of `-0` and `-INF`. */
45
+ readonly indirect?: true;
46
+ }
47
+ /**
48
+ * The indicator rule sets, each sorted by base. `bg` writes its `-` here, where ICU writes it in the rule.
49
+ */
50
+ export declare const INDICATORS: Readonly<Record<IndicatorName, readonly IndicatorRule[]>>;
51
+ /**
52
+ * The rule set of ICU's default locale, en, which a locale without its own rule set falls back to.
53
+ */
54
+ export declare const ROOT_ORDINAL: OrdinalRule;
55
+ /**
56
+ * The rule set that writes a period after the number.
57
+ */
58
+ export declare const DOT_ORDINAL: OrdinalRule;
59
+ /**
60
+ * The rule set of Spanish outside Spain, which writes `º.` where Spain writes `.º`.
61
+ */
62
+ export declare const LATIN_AMERICAN_SPANISH_ORDINAL: OrdinalRule;
63
+ /**
64
+ * ICU's default ordinal rule sets but en's (`ROOT_ORDINAL`), the dot and Latin American Spanish, keyed like `DOT_KEYS`.
65
+ */
66
+ export declare const ORDINAL_RULES: Readonly<Record<string, OrdinalRule>>;
67
+ /**
68
+ * The languages, script variants and scriptless region variants whose rule set writes a period after the number.
69
+ */
70
+ export declare const DOT_KEYS: readonly string[];
71
+ /**
72
+ * The regions whose Spanish uses the Latin American rule set.
73
+ */
74
+ export declare const LATIN_AMERICAN_REGIONS: readonly string[];
75
+ /**
76
+ * Find the ordinal rule set ICU formats a locale with, from the most specific part of its tag this table lists.
77
+ *
78
+ * @param tag - A canonical BCP 47 tag.
79
+ * @returns The listed rule set, or en's when the table lists no part of the tag.
80
+ */
81
+ export declare function ordinalRule(tag: string): OrdinalRule;
82
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/ordinal/rules.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,WAAW,GACjB,MAAM,GACN;IAAE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GAClC;IAAE,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAA;CAAE,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAChC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAC/C,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS;IACjC,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAA;KAAE;CACvD,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,kCAAkC;IAClC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,oFAAoF;IACpF,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;IACvB,oFAAoF;IACpF,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;IACzB,mHAAmH;IACnH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qGAAqG;IACrG,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAC7B,MAAM,CAAC,aAAa,EAAE,SAAS,aAAa,EAAE,CAAC,CA6BlD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,WAE1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,WAA6B,CAAC;AAYxD;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,WAG5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAkE/D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,MAAM,EAqGrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAyBnD,CAAC;AAEF;;;;;GAKG;AAEH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CA6BpD"}
@@ -0,0 +1,203 @@
1
+ import { isUndefined as e } from "@tolki/utils";
2
+ // src/ordinal/rules.ts
3
+ var t = {
4
+ af: [
5
+ [0, "ste"],
6
+ [1, "ste"],
7
+ [2, "de"],
8
+ [20, "ste"],
9
+ [100, { remainder: "af" }]
10
+ ],
11
+ bg: [
12
+ [0, "-и"],
13
+ [1, "-ви"],
14
+ [2, "-ри"],
15
+ [3, "-ти"],
16
+ [5, "-и"],
17
+ [20, { remainder: "bg" }],
18
+ [100, { remainder: "bg-larger" }],
19
+ [1e3, { remainder: "bg" }]
20
+ ],
21
+ "bg-larger": [
22
+ [0, "-тен"],
23
+ [1, { remainder: "bg" }],
24
+ [100, { remainder: "bg-larger" }]
25
+ ],
26
+ ee: [
27
+ [0, " lia"],
28
+ [1, " tɔ"],
29
+ [2, " lia"]
30
+ ]
31
+ }, n = { suffix: { plural: {
32
+ one: "st",
33
+ two: "nd",
34
+ few: "rd",
35
+ other: "th"
36
+ } } }, r = { suffix: "." }, i = {}, a = {
37
+ prefix: "第",
38
+ negative: "第−"
39
+ }, o = {
40
+ suffix: "º.",
41
+ indirect: !0
42
+ }, s = {
43
+ af: { suffix: { indicator: "af" } },
44
+ am: { suffix: "ኛ" },
45
+ ar: i,
46
+ az: { suffix: "'inci" },
47
+ bg: {
48
+ suffix: { indicator: "bg" },
49
+ indirect: !0
50
+ },
51
+ ca: {
52
+ suffix: { plural: {
53
+ one: "r",
54
+ two: "n",
55
+ few: "t",
56
+ other: "è"
57
+ } },
58
+ indirect: !0
59
+ },
60
+ ee: { suffix: { indicator: "ee" } },
61
+ el: i,
62
+ es: {
63
+ suffix: ".º",
64
+ indirect: !0
65
+ },
66
+ fil: { prefix: "ika" },
67
+ fr: {
68
+ suffix: { plural: {
69
+ one: "er",
70
+ other: "e"
71
+ } },
72
+ indirect: !0
73
+ },
74
+ ga: { suffix: "ú" },
75
+ gu: {
76
+ suffix: { plural: {
77
+ one: "લા",
78
+ two: "જા",
79
+ few: "થા",
80
+ many: "્ઠા",
81
+ other: "મા"
82
+ } },
83
+ indian: !0,
84
+ fraction: !0,
85
+ indirect: !0
86
+ },
87
+ he: i,
88
+ hi: {
89
+ suffix: { plural: {
90
+ one: "ला",
91
+ two: "रा",
92
+ few: "था",
93
+ many: "ठा",
94
+ other: "वाँ"
95
+ } },
96
+ indian: !0,
97
+ fraction: !0,
98
+ indirect: !0
99
+ },
100
+ "hi-Latn": n,
101
+ id: {
102
+ prefix: "ke-",
103
+ negative: "−ke-"
104
+ },
105
+ it: {
106
+ suffix: "º",
107
+ indirect: !0
108
+ },
109
+ ja: a,
110
+ kk: { suffix: { plural: {
111
+ many: "-шы",
112
+ other: "-ші"
113
+ } } },
114
+ km: { prefix: "ទី" },
115
+ ko: { suffix: "번째" },
116
+ ky: { suffix: "'инчи" },
117
+ lo: {
118
+ prefix: "ที่​",
119
+ negative: "ที่−"
120
+ },
121
+ ms: {
122
+ prefix: "ke-",
123
+ whole: { 1: "No. 1" },
124
+ negative: "−ke-"
125
+ },
126
+ nl: { suffix: "e" },
127
+ pt: {
128
+ suffix: "º",
129
+ indirect: !0
130
+ },
131
+ ro: { suffix: "a" },
132
+ ru: {},
133
+ sv: {
134
+ suffix: { plural: {
135
+ one: ":a",
136
+ other: ":e"
137
+ } },
138
+ indirect: !0
139
+ },
140
+ ta: {
141
+ suffix: ".",
142
+ indian: !0
143
+ },
144
+ th: {
145
+ prefix: "ที่\xA0",
146
+ negative: "ที่\xA0−"
147
+ },
148
+ uk: {
149
+ suffix: { plural: {
150
+ few: "-ій",
151
+ other: "-ий"
152
+ } },
153
+ indirect: !0
154
+ },
155
+ vi: { prefix: "thứ " },
156
+ yue: a,
157
+ zh: a
158
+ }, c = /* @__PURE__ */ "ak.az-Arab.az-Cyrl.az-IQ.az-IR.az-RU.be.bm-Nkoo.bs.ccp.chr.cs.cy.da.de.dje-Arab.dyo-Arab.en-Dsrt.en-Shaw.eo.et.fa.ff.fi.fo.ha-Arab.ha-CM.ha-SD.hr.hu.hy.is.ka.kk-AF.kk-Arab.kk-CN.kk-IR.kk-MN.kl.kok-Latn.ks-Deva.ku-Arab.ku-IQ.ku-IR.ku-LB.kxv-Deva.kxv-Orya.kxv-Telu.ky-Arab.ky-CN.ky-Latn.lb.lrc.lt.lv.mk.ml-Arab.mn-CN.mn-Mong.mni-Mtei.ms-Arab.ms-CC.mt.my.nb.ne.nn.no.pa-Arab.pa-PK.pl.qu.sat-Deva.sd-Deva.sd-IN.sd-Khoj.sd-Sind.se.shi-Latn.sk.sl.so-Arab.sq.sr.su.sw.tg-Arab.tg-PK.tr.ug-Cyrl.ug-KZ.ug-MN.uz-AF.uz-Arab.uz-CN.uz-Cyrl.vai-Latn.vec.wo-Arab.yo-Arab".split("."), l = [
159
+ "419",
160
+ "AR",
161
+ "BO",
162
+ "BR",
163
+ "BZ",
164
+ "CL",
165
+ "CO",
166
+ "CR",
167
+ "CU",
168
+ "DO",
169
+ "EC",
170
+ "GT",
171
+ "HN",
172
+ "JP",
173
+ "MX",
174
+ "NI",
175
+ "PA",
176
+ "PE",
177
+ "PR",
178
+ "PY",
179
+ "SV",
180
+ "US",
181
+ "UY",
182
+ "VE"
183
+ ];
184
+ /* @__NO_SIDE_EFFECTS__ */
185
+ function u(t) {
186
+ let { language: i, script: a, region: u } = new Intl.Locale(t);
187
+ if (i === "es" && !e(u) && l.includes(u)) return o;
188
+ let d = (e(a) ? [[i, u], [i]] : [
189
+ [
190
+ i,
191
+ a,
192
+ u
193
+ ],
194
+ [i, a],
195
+ [i]
196
+ ]).map((t) => t.filter((t) => !e(t)).join("-"));
197
+ for (let e of d) {
198
+ if (Object.hasOwn(s, e)) return s[e];
199
+ if (c.includes(e)) return r;
200
+ }
201
+ return n;
202
+ }
203
+ export { c as DOT_KEYS, r as DOT_ORDINAL, t as INDICATORS, l as LATIN_AMERICAN_REGIONS, o as LATIN_AMERICAN_SPANISH_ORDINAL, s as ORDINAL_RULES, n as ROOT_ORDINAL, u as ordinalRule };
@@ -8,10 +8,11 @@
8
8
  * the number will be returned as a formatted string instead of spelled out.
9
9
  *
10
10
  * @param number - The number to spell out.
11
- * @param locale - The locale to use for spelling. Defaults to "en-US".
11
+ * @param locale - The locale to use for spelling. Defaults to the default locale.
12
12
  * @param after - If provided, numbers <= this value will be formatted instead of spelled.
13
13
  * @param until - If provided, numbers >= this value will be formatted instead of spelled.
14
14
  * @returns The number spelled out as words, or formatted as a string.
15
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
15
16
  *
16
17
  * @requires {@link https://www.npmjs.com/package/to-words to-words package}
17
18
  *
@@ -22,8 +23,9 @@ export declare function spell(number: number | string, locale?: string | null, a
22
23
  * Spell out the given number in the given locale in ordinal form.
23
24
  *
24
25
  * @param value - The number to spell out in ordinal form.
25
- * @param locale - The locale to use for spelling. Defaults to "en-US".
26
+ * @param locale - The locale to use for spelling. Defaults to the default locale.
26
27
  * @returns The number spelled out as ordinal words (e.g., "First", "Twenty First").
28
+ * @throws Error when ICU has no data for the locale, as PHP's NumberFormatter throws its ValueError
27
29
  *
28
30
  * @requires {@link https://www.npmjs.com/package/to-words to-words package}
29
31
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/speller/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,wBAAsB,KAAK,CACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,GAAE,MAAM,GAAG,IAAW,EAC5B,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,KAAK,GAAE,MAAM,GAAG,IAAW,GAC5B,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED;;;;;;;;;;GAUG;AAEH,wBAAsB,YAAY,CAC9B,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,OAAO,CAAC,MAAM,CAAC,CAKjB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/speller/index.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,wBAAsB,KAAK,CACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,GAAE,MAAM,GAAG,IAAW,EAC5B,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,KAAK,GAAE,MAAM,GAAG,IAAW,GAC5B,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED;;;;;;;;;;;GAWG;AAEH,wBAAsB,YAAY,CAC9B,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,OAAO,CAAC,MAAM,CAAC,CAKjB"}
@@ -1,19 +1,20 @@
1
- import { format as e } from "../num.js";
2
- import { isString as t, toLower as n } from "@tolki/utils";
1
+ import { intlLocale as e } from "../locale/index.js";
2
+ import { defaultLocale as t, format as n } from "../num.js";
3
+ import { isString as r, toLower as i } from "@tolki/utils";
3
4
  // src/speller/index.ts
4
5
  /* @__NO_SIDE_EFFECTS__ */
5
- async function r(r, i = null, o = null, s = null) {
6
- let c = t(r) ? parseFloat(r) : r;
7
- if (o !== null && c <= o || s !== null && c >= s) return /* @__PURE__ */ e(c, null, null, i);
8
- let l = await a(i ?? "en-US");
9
- return n(l.convert(c));
6
+ async function a(a, o = null, c = null, l = null) {
7
+ let u = r(a) ? parseFloat(a) : a;
8
+ if (c !== null && u <= c || l !== null && u >= l) return /* @__PURE__ */ n(u, null, null, o);
9
+ let d = await s(/* @__PURE__ */ e(o ?? /* @__PURE__ */ t()));
10
+ return i(d.convert(u));
10
11
  }
11
12
  /* @__NO_SIDE_EFFECTS__ */
12
- async function i(e, r = null) {
13
- let i = t(e) ? parseFloat(e) : e, o = await a(r ?? "en-US");
14
- return n(o.toOrdinal(Math.floor(i)));
13
+ async function o(n, a = null) {
14
+ let o = r(n) ? parseFloat(n) : n, c = await s(/* @__PURE__ */ e(a ?? /* @__PURE__ */ t()));
15
+ return i(c.toOrdinal(Math.floor(o)));
15
16
  }
16
- async function a(e) {
17
+ async function s(e) {
17
18
  try {
18
19
  return new (await (import(`to-words/${e}`))).ToWords();
19
20
  } catch {}
@@ -84,4 +85,4 @@ async function a(e) {
84
85
  } catch {}
85
86
  return new (await (import("to-words/en-US"))).ToWords();
86
87
  }
87
- export { r as spell, i as spellOrdinal };
88
+ export { a as spell, o as spellOrdinal };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolki/num",
3
- "version": "2.2.6",
3
+ "version": "2.3.0",
4
4
  "description": "Utilities for working with numbers similar to Laravel's Num class facade.",
5
5
  "author": "Abraham Arango <https://github.com/abetwothree>",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "sideEffects": false,
27
27
  "dependencies": {
28
28
  "to-words": "^5.0.0",
29
- "@tolki/utils": "^1.6.4"
29
+ "@tolki/utils": "^1.7.0"
30
30
  },
31
31
  "files": [
32
32
  "dist"
@@ -44,23 +44,19 @@
44
44
  "types": "dist/index.d.ts",
45
45
  "exports": {
46
46
  ".": {
47
- "import": "./dist/index.js",
48
- "require": "./dist/index.js",
49
- "types": "./dist/index.d.ts"
47
+ "types": "./dist/index.d.ts",
48
+ "default": "./dist/index.js"
50
49
  },
51
50
  "./*": {
52
- "import": "./dist/*",
53
- "require": "./dist/*",
54
- "types": "./dist/*"
51
+ "types": "./dist/*",
52
+ "default": "./dist/*"
55
53
  },
56
54
  "./num": {
57
55
  "types": "./dist/num.d.ts",
58
- "import": "./dist/num.js",
59
56
  "default": "./dist/num.js"
60
57
  },
61
58
  "./speller": {
62
59
  "types": "./dist/speller/index.d.ts",
63
- "import": "./dist/speller/index.js",
64
60
  "default": "./dist/speller/index.js"
65
61
  }
66
62
  }