@tolki/num 2.2.5 → 2.2.6
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 +17 -5
- package/dist/num.d.ts +8 -0
- package/dist/num.d.ts.map +1 -1
- package/dist/num.js +34 -16
- package/dist/speller/index.d.ts.map +1 -1
- package/dist/speller/index.js +3 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ pnpm add @tolki/num
|
|
|
28
28
|
|
|
29
29
|
### Importing the Package
|
|
30
30
|
|
|
31
|
-
You can import individual functions
|
|
31
|
+
You can import individual functions or the whole package as a namespace. Both tree-shake the same way:
|
|
32
32
|
|
|
33
33
|
Importing individual functions:
|
|
34
34
|
|
|
@@ -41,10 +41,10 @@ const formattedNumber = format(1234567.89); // '1,234,567.89'
|
|
|
41
41
|
const parsedNumber = parse("1,234,567.89"); // 1234567.89
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
Importing the
|
|
44
|
+
Importing the package as a namespace:
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
|
-
// Import the
|
|
47
|
+
// Import the package as a namespace
|
|
48
48
|
import * as Num from "@tolki/num";
|
|
49
49
|
|
|
50
50
|
// Example usage
|
|
@@ -52,9 +52,21 @@ const formattedNumber = Num.format(1234567.89); // '1,234,567.89'
|
|
|
52
52
|
const parsedNumber = Num.parse("1,234,567.89"); // 1234567.89
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
A namespace import that reads its members by name, such as `Num.format(...)`, shakes exactly like named imports in Rollup, Rolldown (Vite 8), esbuild, webpack and Rspack: your bundle holds only the members you use. Passing the namespace object around, or reading a computed member such as `Num[name]`, keeps every function. See [Bundling and Tree-Shaking](https://tolki.abe.dev/tree-shaking.html#namespace-imports).
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
### Bundling
|
|
58
|
+
|
|
59
|
+
A helper call whose result nothing uses drops out of your bundle in Rollup, Rolldown (Vite 8), webpack and Rspack, because the helpers are marked as free of side effects. This holds for a call at the top level of a module too.
|
|
60
|
+
|
|
61
|
+
The exception is Rspack, where an unused top-level call to `spell` or `spellOrdinal` drops the call but keeps the loader code it needs for the dynamic `import()` of the `to-words` locale files. Writing `/* @__PURE__ */` before the call drops everything:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
export const words = /* @__PURE__ */ spell(5);
|
|
65
|
+
```
|
|
66
|
+
|
|
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
|
+
|
|
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.
|
|
58
70
|
|
|
59
71
|
## Tolki Number Utilities List
|
|
60
72
|
|
package/dist/num.d.ts
CHANGED
|
@@ -180,6 +180,8 @@ export declare function secondsToHuman(seconds: number | string, round?: boolean
|
|
|
180
180
|
/**
|
|
181
181
|
* Execute the given callback using the given locale.
|
|
182
182
|
*
|
|
183
|
+
* @sideEffects callback runs the caller callback around a temporary locale swap
|
|
184
|
+
*
|
|
183
185
|
* @param locale - The locale to use.
|
|
184
186
|
* @param callback - The callback to execute.
|
|
185
187
|
* @returns The result of the callback.
|
|
@@ -190,6 +192,8 @@ export declare function withLocale<TReturn>(locale: string, callback: () => TRet
|
|
|
190
192
|
/**
|
|
191
193
|
* Execute the given callback using the given currency.
|
|
192
194
|
*
|
|
195
|
+
* @sideEffects callback runs the caller callback around a temporary currency swap
|
|
196
|
+
*
|
|
193
197
|
* @param currency - The currency to use.
|
|
194
198
|
* @param callback - The callback to execute.
|
|
195
199
|
* @returns The result of the callback.
|
|
@@ -200,6 +204,8 @@ export declare function withCurrency<TReturn>(currency: string, callback: () =>
|
|
|
200
204
|
/**
|
|
201
205
|
* Set the default locale.
|
|
202
206
|
*
|
|
207
|
+
* @sideEffects state writes the module default locale
|
|
208
|
+
*
|
|
203
209
|
* @param locale - The locale to set.
|
|
204
210
|
* @returns void
|
|
205
211
|
*
|
|
@@ -209,6 +215,8 @@ export declare function useLocale(locale: string): void;
|
|
|
209
215
|
/**
|
|
210
216
|
* Set the default currency.
|
|
211
217
|
*
|
|
218
|
+
* @sideEffects state writes the module default currency
|
|
219
|
+
*
|
|
212
220
|
* @param currency - The currency to set.
|
|
213
221
|
* @returns void
|
|
214
222
|
*
|
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;
|
|
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,MAAM,GAAG,KAAK,CAqBhB;AAED;;;;;;;;;;GAUG;AAEH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAM,GAAG,IAAW,GAAG,MAAM,CA2DzE;AAED;;;;;;;;GAQG;AAEH,wBAAgB,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,GAAG,KAAK,CAQhB;AAED;;;;;;;;GAQG;AAEH,wBAAgB,UAAU,CACtB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,GAAG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FFECTS__ */
|
|
4
5
|
function r(e, t = 0, n = null) {
|
|
5
|
-
return f(e, t, n, !0);
|
|
6
|
+
return /* @__PURE__ */ f(e, t, n, !0);
|
|
6
7
|
}
|
|
8
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
7
9
|
function i(e, n = null, r = null, i = null) {
|
|
8
10
|
i ??= t;
|
|
9
11
|
let a = {
|
|
@@ -14,6 +16,7 @@ function i(e, n = null, r = null, i = null) {
|
|
|
14
16
|
let o = new Intl.NumberFormat(i, a);
|
|
15
17
|
return o.format(T(e, o.format));
|
|
16
18
|
}
|
|
19
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
17
20
|
function a(e, n = null) {
|
|
18
21
|
n ??= t;
|
|
19
22
|
let r = new Intl.NumberFormat(n).formatToParts(12345.6), i = /* @__PURE__ */ new Set(), a = ".";
|
|
@@ -34,13 +37,16 @@ function a(e, n = null) {
|
|
|
34
37
|
}
|
|
35
38
|
return o = o.replace(/[\s\u00A0\u202F\u2009]+/g, "").trim(), globalThis.Number(o);
|
|
36
39
|
}
|
|
40
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
37
41
|
function o(e, t = null) {
|
|
38
|
-
let n = a(e, t);
|
|
42
|
+
let n = /* @__PURE__ */ a(e, t);
|
|
39
43
|
return Number.isNaN(n) ? !1 : n < 0 ? Math.ceil(n) : Math.floor(n);
|
|
40
44
|
}
|
|
45
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
41
46
|
function s(e, t = null) {
|
|
42
|
-
return a(e, t);
|
|
47
|
+
return /* @__PURE__ */ a(e, t);
|
|
43
48
|
}
|
|
49
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
44
50
|
function c(e, n = null) {
|
|
45
51
|
let r = n ?? t;
|
|
46
52
|
try {
|
|
@@ -62,8 +68,9 @@ function c(e, n = null) {
|
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
}
|
|
71
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
65
72
|
function l(e, n = 0, r = null, i = null) {
|
|
66
|
-
let o = i ?? t, s = typeof e == "string" ? a(e, o) : e, c = {
|
|
73
|
+
let o = i ?? t, s = typeof e == "string" ? /* @__PURE__ */ a(e, o) : e, c = {
|
|
67
74
|
style: "percent",
|
|
68
75
|
useGrouping: !0
|
|
69
76
|
};
|
|
@@ -71,8 +78,9 @@ function l(e, n = 0, r = null, i = null) {
|
|
|
71
78
|
let l = new Intl.NumberFormat(o, c);
|
|
72
79
|
return l.format(T(s / 100, l.format));
|
|
73
80
|
}
|
|
81
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
74
82
|
function u(e, r = "", i = null, o = null) {
|
|
75
|
-
let s = i ?? t, c = typeof e == "string" ? a(e, s) : e, l = {
|
|
83
|
+
let s = i ?? t, c = typeof e == "string" ? /* @__PURE__ */ a(e, s) : e, l = {
|
|
76
84
|
style: "currency",
|
|
77
85
|
currency: r && r.length ? r : n,
|
|
78
86
|
useGrouping: !0
|
|
@@ -81,9 +89,10 @@ function u(e, r = "", i = null, o = null) {
|
|
|
81
89
|
let u = new Intl.NumberFormat(s, l);
|
|
82
90
|
return u.format(T(c, u.format));
|
|
83
91
|
}
|
|
92
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
84
93
|
function d(e, t = 0, n = null) {
|
|
85
94
|
let r = typeof e == "string" ? Number(e) : e;
|
|
86
|
-
if (!Number.isFinite(r)) return `${i(r, t, n)} B`;
|
|
95
|
+
if (!Number.isFinite(r)) return `${/* @__PURE__ */ i(r, t, n)} B`;
|
|
87
96
|
let a = [
|
|
88
97
|
"B",
|
|
89
98
|
"KB",
|
|
@@ -96,10 +105,11 @@ function d(e, t = 0, n = null) {
|
|
|
96
105
|
"YB"
|
|
97
106
|
], o = a.length, s = 0;
|
|
98
107
|
for (; Math.abs(r) / 1024 > .9 && s < o - 1;) r /= 1024, s++;
|
|
99
|
-
return `${i(r, t, n)} ${a[s]}`;
|
|
108
|
+
return `${/* @__PURE__ */ i(r, t, n)} ${a[s]}`;
|
|
100
109
|
}
|
|
110
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
101
111
|
function f(e, t = 0, n = null, r = !1) {
|
|
102
|
-
return p(e, t, n, r ? {} : {
|
|
112
|
+
return /* @__PURE__ */ p(e, t, n, r ? {} : {
|
|
103
113
|
3: " thousand",
|
|
104
114
|
6: " million",
|
|
105
115
|
9: " billion",
|
|
@@ -107,35 +117,38 @@ function f(e, t = 0, n = null, r = !1) {
|
|
|
107
117
|
15: " quadrillion"
|
|
108
118
|
});
|
|
109
119
|
}
|
|
120
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
110
121
|
function p(e, t = 0, n = null, r = {}) {
|
|
111
|
-
if (!Number.isFinite(e)) return i(e, t, n);
|
|
122
|
+
if (!Number.isFinite(e)) return /* @__PURE__ */ i(e, t, n);
|
|
112
123
|
if (Object.keys(r).length === 0 && (r = {
|
|
113
124
|
3: "K",
|
|
114
125
|
6: "M",
|
|
115
126
|
9: "B",
|
|
116
127
|
12: "T",
|
|
117
128
|
15: "Q"
|
|
118
|
-
}), Number(e) === 0) return t > 0 ? i(0, t, n) : "0";
|
|
129
|
+
}), Number(e) === 0) return t > 0 ? /* @__PURE__ */ i(0, t, n) : "0";
|
|
119
130
|
if (e < 0) {
|
|
120
|
-
let i = p(Math.abs(e), t, n, r);
|
|
121
|
-
return i === p(0, t, n, r) ? i : `-${i}`;
|
|
131
|
+
let i = /* @__PURE__ */ p(Math.abs(e), t, n, r);
|
|
132
|
+
return i === /* @__PURE__ */ p(0, t, n, r) ? i : `-${i}`;
|
|
122
133
|
}
|
|
123
134
|
if (e >= 0x38d7ea4c68000) {
|
|
124
135
|
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];
|
|
125
|
-
return `${p(e / 0x38d7ea4c68000, t, n, r)}${o}`.trim();
|
|
136
|
+
return `${/* @__PURE__ */ p(e / 0x38d7ea4c68000, t, n, r)}${o}`.trim();
|
|
126
137
|
}
|
|
127
138
|
let o = Math.floor(Math.log10(e)), s = Math.max(0, o - o % 3), c = e / 10 ** s, l;
|
|
128
|
-
if (l = n == null ? t > 0 ? i(c, t, null) : s === 3 && c < 10 && Math.abs(e) % 10 == 0 ? i(c, null, 1) : i(c, 0, null) : i(c, null, n), a(l) >= 1e3 && r[s + 3] !== void 0) {
|
|
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) {
|
|
129
140
|
s += 3;
|
|
130
141
|
let e = c / 1e3;
|
|
131
|
-
l = n == null ? t > 0 ? i(e, t, null) : i(e, 0, null) : i(e, null, n);
|
|
142
|
+
l = n == null ? t > 0 ? /* @__PURE__ */ i(e, t, null) : /* @__PURE__ */ i(e, 0, null) : /* @__PURE__ */ i(e, null, n);
|
|
132
143
|
}
|
|
133
144
|
let u = r[s] ?? "";
|
|
134
145
|
return `${l}${u}`.trim();
|
|
135
146
|
}
|
|
147
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
136
148
|
function m(e, t, n) {
|
|
137
149
|
return Math.min(Math.max(e, t), n);
|
|
138
150
|
}
|
|
151
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
139
152
|
function h(t, n, r = 0, i = 1) {
|
|
140
153
|
if (n === 0) throw new e("The $by argument must not be zero.");
|
|
141
154
|
n = Math.abs(n);
|
|
@@ -147,12 +160,15 @@ function h(t, n, r = 0, i = 1) {
|
|
|
147
160
|
let s = a.at(-1);
|
|
148
161
|
return s !== void 0 && o === t && s[1] < t && a.push([o, t]), a;
|
|
149
162
|
}
|
|
163
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
150
164
|
function g(e) {
|
|
151
165
|
return isFinite(e) ? JSON.parse(JSON.stringify(e)) : e;
|
|
152
166
|
}
|
|
167
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
153
168
|
function _(e, t = !0) {
|
|
154
|
-
return v(Number(e) * 60, t);
|
|
169
|
+
return /* @__PURE__ */ v(Number(e) * 60, t);
|
|
155
170
|
}
|
|
171
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
156
172
|
function v(e, t = !0) {
|
|
157
173
|
let n = Number(e);
|
|
158
174
|
if ((!Number.isFinite(n) || n < 0) && (n = 0), n === 0) return "0 seconds";
|
|
@@ -203,9 +219,11 @@ function x(e) {
|
|
|
203
219
|
function S(e) {
|
|
204
220
|
n = e;
|
|
205
221
|
}
|
|
222
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
206
223
|
function C() {
|
|
207
224
|
return t;
|
|
208
225
|
}
|
|
226
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
209
227
|
function w() {
|
|
210
228
|
return n;
|
|
211
229
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/speller/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
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"}
|
package/dist/speller/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { format as e } from "../num.js";
|
|
2
2
|
import { isString as t, toLower as n } from "@tolki/utils";
|
|
3
3
|
// src/speller/index.ts
|
|
4
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
4
5
|
async function r(r, i = null, o = null, s = null) {
|
|
5
6
|
let c = t(r) ? parseFloat(r) : r;
|
|
6
|
-
if (o !== null && c <= o || s !== null && c >= s) return e(c, null, null, i);
|
|
7
|
+
if (o !== null && c <= o || s !== null && c >= s) return /* @__PURE__ */ e(c, null, null, i);
|
|
7
8
|
let l = await a(i ?? "en-US");
|
|
8
9
|
return n(l.convert(c));
|
|
9
10
|
}
|
|
11
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
10
12
|
async function i(e, r = null) {
|
|
11
13
|
let i = t(e) ? parseFloat(e) : e, o = await a(r ?? "en-US");
|
|
12
14
|
return n(o.toOrdinal(Math.floor(i)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/num",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
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.
|
|
29
|
+
"@tolki/utils": "^1.6.4"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"dist"
|