@zinaid/num 0.0.1
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/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/num.d.ts +201 -0
- package/dist/num.d.ts.map +1 -0
- package/dist/num.js +258 -0
- package/dist/speller.d.ts +7 -0
- package/dist/speller.d.ts.map +1 -0
- package/dist/speller.js +3369 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Abraham Arango
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { clamp as a, currency as l, defaultCurrency as o, defaultLocale as n, fileSize as s, forHumans as u, format as t, minutesToHuman as c, ordinal as m, pairs as p, parse as i, parseFloat as f, parseInt as d, percentage as y, secondsToHuman as C, spell as H, spellOrdinal as L, summarize as h, trim as w, useCurrency as x, useLocale as z, withCurrency as S, withLocale as T } from "./num.js";
|
|
2
|
+
import { Speller as F } from "./speller.js";
|
|
3
|
+
export {
|
|
4
|
+
F as Speller,
|
|
5
|
+
a as clamp,
|
|
6
|
+
l as currency,
|
|
7
|
+
o as defaultCurrency,
|
|
8
|
+
n as defaultLocale,
|
|
9
|
+
s as fileSize,
|
|
10
|
+
u as forHumans,
|
|
11
|
+
t as format,
|
|
12
|
+
c as minutesToHuman,
|
|
13
|
+
m as ordinal,
|
|
14
|
+
p as pairs,
|
|
15
|
+
i as parse,
|
|
16
|
+
f as parseFloat,
|
|
17
|
+
d as parseInt,
|
|
18
|
+
y as percentage,
|
|
19
|
+
C as secondsToHuman,
|
|
20
|
+
H as spell,
|
|
21
|
+
L as spellOrdinal,
|
|
22
|
+
h as summarize,
|
|
23
|
+
w as trim,
|
|
24
|
+
x as useCurrency,
|
|
25
|
+
z as useLocale,
|
|
26
|
+
S as withCurrency,
|
|
27
|
+
T as withLocale
|
|
28
|
+
};
|
package/dist/num.d.ts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format the given number according to the current locale.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* format(1234.5678, 2); // "1,234.57"
|
|
7
|
+
* format(1234.5678, 2, 4); // "1,234.5678"
|
|
8
|
+
* format(1234.5678, 2, 4, "de"); // "1.234,5678"
|
|
9
|
+
*/
|
|
10
|
+
export declare function format(number: number, precision?: number | null, maxPrecision?: number | null, locale?: string | null): string | false;
|
|
11
|
+
/**
|
|
12
|
+
* Parse the given string according to the specified format type.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
*
|
|
16
|
+
* parse("1,234.57"); // 1234.57
|
|
17
|
+
*/
|
|
18
|
+
export declare function parse(value: string, locale?: string | null): number;
|
|
19
|
+
/**
|
|
20
|
+
* Parse a string into an integer according to the specified locale.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* parseInt("1,234", "en"); // 1234
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseInt(value: string, locale?: string | null): number | false;
|
|
27
|
+
/**
|
|
28
|
+
* Parse a string into a float according to the specified locale.
|
|
29
|
+
*
|
|
30
|
+
* @param string $string
|
|
31
|
+
* @param string|null $locale
|
|
32
|
+
* @return float|false
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseFloat(value: string, locale?: string | null): number | false;
|
|
35
|
+
/**
|
|
36
|
+
* Spell out the given number in the given locale.
|
|
37
|
+
* @todo
|
|
38
|
+
*/
|
|
39
|
+
export declare function spell(_number: number | string, _locale?: string | null, _after?: number | null, _until?: number | null): string;
|
|
40
|
+
/**
|
|
41
|
+
* Convert the given number to ordinal form.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
*
|
|
45
|
+
* ordinal(1); // "1st"
|
|
46
|
+
* ordinal(2); // "2nd"
|
|
47
|
+
* ordinal(3); // "3rd"
|
|
48
|
+
* ordinal(13); // "13th"
|
|
49
|
+
*/
|
|
50
|
+
export declare function ordinal(value: number, locale?: string | null): string;
|
|
51
|
+
/**
|
|
52
|
+
* Spell out the given number in the given locale in ordinal form.
|
|
53
|
+
* @todo
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* spellOrdinal(1); // "first"
|
|
58
|
+
* spellOrdinal(2); // "second"
|
|
59
|
+
* spellOrdinal(3); // "third"
|
|
60
|
+
*/
|
|
61
|
+
export declare function spellOrdinal(_value: number, _locale?: string | null): string;
|
|
62
|
+
/**
|
|
63
|
+
* Convert the given number to its percentage equivalent.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
*
|
|
67
|
+
* percentage(1); // "1%"
|
|
68
|
+
* percentage(1.75, 2); // "1.75%"
|
|
69
|
+
* percentage(0.12345, 4); // "0.1235%"
|
|
70
|
+
*/
|
|
71
|
+
export declare function percentage(number: number | string, precision?: number, maxPrecision?: number | null, locale?: string | null): string | false;
|
|
72
|
+
/**
|
|
73
|
+
* Convert the given number to its currency equivalent.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
*
|
|
77
|
+
* currency(5.00); // "$5.00"
|
|
78
|
+
* currency(-5); // "-$5.00"
|
|
79
|
+
* currency(10, 'EUR'); // "€10.00"
|
|
80
|
+
*/
|
|
81
|
+
export declare function currency(amount: number | string, currencyCode?: string, locale?: string | null, precision?: number | null): string | false;
|
|
82
|
+
/**
|
|
83
|
+
* Convert the given number to its file size equivalent.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
*
|
|
87
|
+
* fileSize(1024); // "1 KB"
|
|
88
|
+
* fileSize(2048); // "2 KB"
|
|
89
|
+
* fileSize(1264.12345, 3); // "1.234 KB"
|
|
90
|
+
*/
|
|
91
|
+
export declare function fileSize(bytes: number | string, precision?: number, maxPrecision?: number | null): string;
|
|
92
|
+
/**
|
|
93
|
+
* Convert the number to its human-readable equivalent.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
*
|
|
97
|
+
* forHumans(1234); // "1.234 thousand"
|
|
98
|
+
* forHumans(1234567); // "1.234 million"
|
|
99
|
+
* forHumans(1234567890); // "1.234 billion"
|
|
100
|
+
*/
|
|
101
|
+
export declare function forHumans(value: number, precision?: number, maxPrecision?: number | null, abbreviate?: boolean): string | false;
|
|
102
|
+
/**
|
|
103
|
+
* Convert the number to its human-readable equivalent.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
*
|
|
107
|
+
* summarize(1234); // "1.234 K"
|
|
108
|
+
* summarize(1234567); // "1.234 M"
|
|
109
|
+
* summarize(1234567890); // "1.234 B"
|
|
110
|
+
*/
|
|
111
|
+
export declare function summarize(value: number, precision?: number, maxPrecision?: number | null, units?: Record<number, string>): string | false;
|
|
112
|
+
/**
|
|
113
|
+
* Clamp the given number between the given minimum and maximum.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
*
|
|
117
|
+
* clamp(5, 1, 10); // 5
|
|
118
|
+
* clamp(0, 1, 10); // 1
|
|
119
|
+
* clamp(15, 1, 10); // 10
|
|
120
|
+
*/
|
|
121
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
122
|
+
/**
|
|
123
|
+
* Split the given number into pairs of min/max values.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
*
|
|
127
|
+
* pairs(25, 10, 1, 1); // [[1, 11], [11, 21], [21, 25]]
|
|
128
|
+
*/
|
|
129
|
+
export declare function pairs(to: number, by: number, start?: number, offset?: number): [number, number][];
|
|
130
|
+
/**
|
|
131
|
+
* Remove any trailing zero digits after the decimal point of the given number.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
*
|
|
135
|
+
* trim(12.3456789); // 12.3456789
|
|
136
|
+
* trim(12.34567890000); // 12.3456789
|
|
137
|
+
*/
|
|
138
|
+
export declare function trim(value: number): number;
|
|
139
|
+
/**
|
|
140
|
+
* Convert a duration in minutes to a human-readable format.
|
|
141
|
+
*
|
|
142
|
+
* @param minutes The duration in minutes.
|
|
143
|
+
* @param round Whether to round to the nearest unit.
|
|
144
|
+
* @returns The human-readable duration string.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
*
|
|
148
|
+
* minutesToHuman(61); // "1 hour"
|
|
149
|
+
* minutesToHuman(61, false); // "1 hour, 1 minute"
|
|
150
|
+
*/
|
|
151
|
+
export declare function minutesToHuman(minutes: number | string, round?: boolean): string;
|
|
152
|
+
/**
|
|
153
|
+
* Convert a duration in seconds to a human-readable format.
|
|
154
|
+
*
|
|
155
|
+
* @param seconds The duration in seconds.
|
|
156
|
+
* @param round Whether to round to the nearest unit.
|
|
157
|
+
* @returns The human-readable duration string.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
*
|
|
161
|
+
* secondsToHuman(3661); // "1 hour"
|
|
162
|
+
* secondsToHuman(3661, false); // "1 hour, 1 minute, 1 second"
|
|
163
|
+
*/
|
|
164
|
+
export declare function secondsToHuman(seconds: number | string, round?: boolean): string;
|
|
165
|
+
/**
|
|
166
|
+
* Execute the given callback using the given locale.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
*
|
|
170
|
+
* withLocale("fr", () => {
|
|
171
|
+
* return format(1234.56);
|
|
172
|
+
* }); // "1 234,56"
|
|
173
|
+
*/
|
|
174
|
+
export declare function withLocale(locale: string, callback: () => unknown): unknown;
|
|
175
|
+
/**
|
|
176
|
+
* Execute the given callback using the given currency.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
*
|
|
180
|
+
* withCurrency("EUR", () => {
|
|
181
|
+
* return format(1234.56);
|
|
182
|
+
* }); // "€1,234.56"
|
|
183
|
+
*/
|
|
184
|
+
export declare function withCurrency(currency: string, callback: () => unknown): unknown;
|
|
185
|
+
/**
|
|
186
|
+
* Set the default locale.
|
|
187
|
+
*/
|
|
188
|
+
export declare function useLocale(locale: string): void;
|
|
189
|
+
/**
|
|
190
|
+
* Set the default currency.
|
|
191
|
+
*/
|
|
192
|
+
export declare function useCurrency(currency: string): void;
|
|
193
|
+
/**
|
|
194
|
+
* Get the default locale.
|
|
195
|
+
*/
|
|
196
|
+
export declare function defaultLocale(): string;
|
|
197
|
+
/**
|
|
198
|
+
* Get the default currency.
|
|
199
|
+
*/
|
|
200
|
+
export declare function defaultCurrency(): string;
|
|
201
|
+
//# sourceMappingURL=num.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"num.d.ts","sourceRoot":"","sources":["../src/num.ts"],"names":[],"mappings":"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"}
|
package/dist/num.js
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
let m = "en", y = "USD";
|
|
2
|
+
function g(t, n = null, e = null, r = null) {
|
|
3
|
+
r = r ?? m;
|
|
4
|
+
const o = {
|
|
5
|
+
style: "decimal",
|
|
6
|
+
useGrouping: !0
|
|
7
|
+
};
|
|
8
|
+
return e != null ? (o.maximumFractionDigits = e, o.minimumFractionDigits = 0) : n != null && (o.minimumFractionDigits = n, o.maximumFractionDigits = n), new Intl.NumberFormat(r, o).format(t);
|
|
9
|
+
}
|
|
10
|
+
function $(t, n = null) {
|
|
11
|
+
n = n ?? m;
|
|
12
|
+
const r = new Intl.NumberFormat(n).formatToParts(12345.6), o = /* @__PURE__ */ new Set();
|
|
13
|
+
let s = ".";
|
|
14
|
+
for (const i of r)
|
|
15
|
+
i.type === "group" ? o.add(i.value) : i.type === "decimal" && (s = i.value);
|
|
16
|
+
const u = [" ", " ", " "];
|
|
17
|
+
for (const i of u) o.add(i);
|
|
18
|
+
let l = t;
|
|
19
|
+
for (const i of o) {
|
|
20
|
+
const c = new RegExp(
|
|
21
|
+
i.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"),
|
|
22
|
+
"g"
|
|
23
|
+
);
|
|
24
|
+
l = l.replace(c, "");
|
|
25
|
+
}
|
|
26
|
+
if (s !== ".") {
|
|
27
|
+
const i = new RegExp(
|
|
28
|
+
s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"),
|
|
29
|
+
"g"
|
|
30
|
+
), c = l.lastIndexOf(s);
|
|
31
|
+
c !== -1 && (l = l.slice(0, c).replace(i, "") + "." + l.slice(c + s.length));
|
|
32
|
+
}
|
|
33
|
+
return l = l.replace(/[\s\u00A0\u202F\u2009]+/g, "").trim(), globalThis.Number(l);
|
|
34
|
+
}
|
|
35
|
+
function S(t, n = null) {
|
|
36
|
+
const e = $(t, n);
|
|
37
|
+
return Number.isNaN(e) ? !1 : e < 0 ? Math.ceil(e) : Math.floor(e);
|
|
38
|
+
}
|
|
39
|
+
function x(t, n = null) {
|
|
40
|
+
return $(t, n);
|
|
41
|
+
}
|
|
42
|
+
function E(t, n = null, e = null, r = null) {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
function O(t, n = null) {
|
|
46
|
+
const e = n ?? m;
|
|
47
|
+
try {
|
|
48
|
+
const o = new Intl.PluralRules(e, { type: "ordinal" }).select(t), s = e.split("-")[0] || "en", u = {
|
|
49
|
+
en: { one: "st", two: "nd", few: "rd", other: "th" }
|
|
50
|
+
}, l = u[s] ?? u.en, p = l[o] ?? l.other;
|
|
51
|
+
return `${t}${p}`;
|
|
52
|
+
} catch {
|
|
53
|
+
const r = Math.abs(t), o = r % 100;
|
|
54
|
+
if (o >= 11 && o <= 13)
|
|
55
|
+
return `${t}th`;
|
|
56
|
+
switch (r % 10) {
|
|
57
|
+
case 1:
|
|
58
|
+
return `${t}st`;
|
|
59
|
+
case 2:
|
|
60
|
+
return `${t}nd`;
|
|
61
|
+
case 3:
|
|
62
|
+
return `${t}rd`;
|
|
63
|
+
default:
|
|
64
|
+
return `${t}th`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function B(t, n = null) {
|
|
69
|
+
return "";
|
|
70
|
+
}
|
|
71
|
+
function I(t, n = 0, e = null, r = null) {
|
|
72
|
+
const o = r ?? m, s = typeof t == "string" ? $(t, o) : t, u = {
|
|
73
|
+
style: "percent",
|
|
74
|
+
useGrouping: !0
|
|
75
|
+
};
|
|
76
|
+
return e != null ? (u.maximumFractionDigits = e, u.minimumFractionDigits = 0) : (u.minimumFractionDigits = n, u.maximumFractionDigits = n), new Intl.NumberFormat(o, u).format(s / 100);
|
|
77
|
+
}
|
|
78
|
+
function T(t, n = "", e = null, r = null) {
|
|
79
|
+
const o = e ?? m, s = typeof t == "string" ? $(t, o) : t, l = {
|
|
80
|
+
style: "currency",
|
|
81
|
+
currency: n && n.length ? n : y,
|
|
82
|
+
useGrouping: !0
|
|
83
|
+
};
|
|
84
|
+
return r != null && (l.minimumFractionDigits = r, l.maximumFractionDigits = r), new Intl.NumberFormat(o, l).format(s);
|
|
85
|
+
}
|
|
86
|
+
function _(t, n = 0, e = null) {
|
|
87
|
+
let r = typeof t == "string" ? Number(t) : t;
|
|
88
|
+
Number.isFinite(r) || (r = 0);
|
|
89
|
+
const o = [
|
|
90
|
+
"B",
|
|
91
|
+
"KB",
|
|
92
|
+
"MB",
|
|
93
|
+
"GB",
|
|
94
|
+
"TB",
|
|
95
|
+
"PB",
|
|
96
|
+
"EB",
|
|
97
|
+
"ZB",
|
|
98
|
+
"YB"
|
|
99
|
+
], s = o.length;
|
|
100
|
+
let u = 0;
|
|
101
|
+
for (; r / 1024 > 0.9 && u < s - 1; )
|
|
102
|
+
r /= 1024, u++;
|
|
103
|
+
return `${g(r, n, e)} ${o[u]}`;
|
|
104
|
+
}
|
|
105
|
+
function R(t, n = 0, e = null, r = !1) {
|
|
106
|
+
return b(
|
|
107
|
+
t,
|
|
108
|
+
n,
|
|
109
|
+
e,
|
|
110
|
+
r ? {} : {
|
|
111
|
+
3: " thousand",
|
|
112
|
+
6: " million",
|
|
113
|
+
9: " billion",
|
|
114
|
+
12: " trillion",
|
|
115
|
+
15: " quadrillion"
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function b(t, n = 0, e = null, r = {}) {
|
|
120
|
+
if (Object.keys(r).length === 0 && (r = {
|
|
121
|
+
3: "K",
|
|
122
|
+
6: "M",
|
|
123
|
+
9: "B",
|
|
124
|
+
12: "T",
|
|
125
|
+
15: "Q"
|
|
126
|
+
}), Number(t) === 0)
|
|
127
|
+
return n > 0 ? g(0, n, e) : "0";
|
|
128
|
+
if (t < 0)
|
|
129
|
+
return `-${b(
|
|
130
|
+
Math.abs(t),
|
|
131
|
+
n,
|
|
132
|
+
e,
|
|
133
|
+
r
|
|
134
|
+
)}`;
|
|
135
|
+
if (t >= 1e15) {
|
|
136
|
+
const i = Object.keys(r).map((a) => Number(a)).filter((a) => !Number.isNaN(a)).sort((a, f) => a - f), c = i[i.length - 1], h = r[c];
|
|
137
|
+
return `${b(
|
|
138
|
+
t / 1e15,
|
|
139
|
+
n,
|
|
140
|
+
e,
|
|
141
|
+
r
|
|
142
|
+
)}${h}`.trim();
|
|
143
|
+
}
|
|
144
|
+
const o = Math.floor(Math.log10(t)), s = o - o % 3, u = t / Math.pow(10, s);
|
|
145
|
+
let l;
|
|
146
|
+
if (e != null)
|
|
147
|
+
l = g(u, null, e);
|
|
148
|
+
else if (n > 0)
|
|
149
|
+
l = g(u, n, null);
|
|
150
|
+
else {
|
|
151
|
+
const i = Math.abs(t);
|
|
152
|
+
l = s === 3 && u < 10 && i % 10 === 0 ? g(u, null, 1) : g(u, 0, null);
|
|
153
|
+
}
|
|
154
|
+
const p = r[s] ?? "";
|
|
155
|
+
return `${l}${p}`.trim();
|
|
156
|
+
}
|
|
157
|
+
function G(t, n, e) {
|
|
158
|
+
return Math.min(Math.max(t, n), e);
|
|
159
|
+
}
|
|
160
|
+
function H(t, n, e = 0, r = 1) {
|
|
161
|
+
const o = [];
|
|
162
|
+
for (let s = e; s < t; s += n) {
|
|
163
|
+
let u = s + n - r;
|
|
164
|
+
u > t && (u = t), o.push([s, u]);
|
|
165
|
+
}
|
|
166
|
+
return o;
|
|
167
|
+
}
|
|
168
|
+
function k(t) {
|
|
169
|
+
return JSON.parse(JSON.stringify(t));
|
|
170
|
+
}
|
|
171
|
+
function A(t, n = !0) {
|
|
172
|
+
const e = Number(t) * 60;
|
|
173
|
+
return D(e, n);
|
|
174
|
+
}
|
|
175
|
+
function D(t, n = !0) {
|
|
176
|
+
let e = Number(t);
|
|
177
|
+
if ((!Number.isFinite(e) || e < 0) && (e = 0), e === 0) return "0 seconds";
|
|
178
|
+
const r = 1, o = 60 * r, s = 60 * o, u = 24 * s, l = 7 * u, p = 4 * l, c = [
|
|
179
|
+
["year", 12 * p],
|
|
180
|
+
["month", p],
|
|
181
|
+
["week", l],
|
|
182
|
+
["day", u],
|
|
183
|
+
["hour", s],
|
|
184
|
+
["minute", o],
|
|
185
|
+
["second", r]
|
|
186
|
+
];
|
|
187
|
+
if (n)
|
|
188
|
+
for (const [a, f] of c) {
|
|
189
|
+
const d = e / f;
|
|
190
|
+
if (d >= 0.5 || f === r) {
|
|
191
|
+
const F = Math.round(d);
|
|
192
|
+
return `${F} ${a}${F === 1 ? "" : "s"}`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
let h = e;
|
|
196
|
+
const N = [];
|
|
197
|
+
for (const [a, f] of c)
|
|
198
|
+
if (h >= f) {
|
|
199
|
+
const d = Math.floor(h / f);
|
|
200
|
+
h -= d * f, N.push(`${d} ${a}${d === 1 ? "" : "s"}`);
|
|
201
|
+
}
|
|
202
|
+
return N.join(", ");
|
|
203
|
+
}
|
|
204
|
+
function C(t, n) {
|
|
205
|
+
const e = m;
|
|
206
|
+
w(t);
|
|
207
|
+
try {
|
|
208
|
+
return n();
|
|
209
|
+
} finally {
|
|
210
|
+
w(e);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function K(t, n) {
|
|
214
|
+
const e = y;
|
|
215
|
+
M(t);
|
|
216
|
+
try {
|
|
217
|
+
return n();
|
|
218
|
+
} finally {
|
|
219
|
+
M(e);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function w(t) {
|
|
223
|
+
m = t;
|
|
224
|
+
}
|
|
225
|
+
function M(t) {
|
|
226
|
+
y = t;
|
|
227
|
+
}
|
|
228
|
+
function L() {
|
|
229
|
+
return m;
|
|
230
|
+
}
|
|
231
|
+
function Y() {
|
|
232
|
+
return y;
|
|
233
|
+
}
|
|
234
|
+
export {
|
|
235
|
+
G as clamp,
|
|
236
|
+
T as currency,
|
|
237
|
+
Y as defaultCurrency,
|
|
238
|
+
L as defaultLocale,
|
|
239
|
+
_ as fileSize,
|
|
240
|
+
R as forHumans,
|
|
241
|
+
g as format,
|
|
242
|
+
A as minutesToHuman,
|
|
243
|
+
O as ordinal,
|
|
244
|
+
H as pairs,
|
|
245
|
+
$ as parse,
|
|
246
|
+
x as parseFloat,
|
|
247
|
+
S as parseInt,
|
|
248
|
+
I as percentage,
|
|
249
|
+
D as secondsToHuman,
|
|
250
|
+
E as spell,
|
|
251
|
+
B as spellOrdinal,
|
|
252
|
+
b as summarize,
|
|
253
|
+
k as trim,
|
|
254
|
+
M as useCurrency,
|
|
255
|
+
w as useLocale,
|
|
256
|
+
K as withCurrency,
|
|
257
|
+
C as withLocale
|
|
258
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speller.d.ts","sourceRoot":"","sources":["../src/speller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,qBAAa,OAAO;IAChB,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;;IAMpB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAG1C"}
|