@primoui/utils 1.4.0 → 1.4.2
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/dist/format/format.d.ts +2 -1
- package/dist/format/format.d.ts.map +1 -1
- package/dist/http/http.d.ts +3 -1
- package/dist/http/http.d.ts.map +1 -1
- package/dist/index.js +151 -158
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -6
package/dist/format/format.d.ts
CHANGED
|
@@ -15,9 +15,10 @@ export declare const formatNumber: (number: number, notation?: Notation, locale?
|
|
|
15
15
|
* Formats a given amount of money into a currency string.
|
|
16
16
|
* @param amount The amount of money to format.
|
|
17
17
|
* @param currency The currency to format the amount in. Defaults to 'USD'.
|
|
18
|
+
* @param locale - The locale to use for formatting. Defaults to 'en-US'.
|
|
18
19
|
* @returns The formatted currency string.
|
|
19
20
|
*/
|
|
20
|
-
export declare const formatCurrency: (amount: number, currency?: Currency) => string;
|
|
21
|
+
export declare const formatCurrency: (amount: number, currency?: Currency, locale?: string) => string;
|
|
21
22
|
/**
|
|
22
23
|
* Formats a given amount with an interval
|
|
23
24
|
* @param amount The amount of money to format.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/format/format.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,KAAK,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;AACpD,KAAK,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,WAAU,QAAoB,EAAE,eAAgB,WAI5F,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/format/format.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,KAAK,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;AACpD,KAAK,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;AAEpD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,EAAE,WAAU,QAAoB,EAAE,eAAgB,WAI5F,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,WAAU,QAAgB,EAAE,eAAgB,WAO1F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,EAAE,WAAU,OAAO,GAAG,MAAgB,WAExF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,kBAAa,KAAG,MAEhE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,kBAAa,KAAG,MAc1D,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,MAAM,GAAG,SAY1D,CAAA"}
|
package/dist/http/http.d.ts
CHANGED
|
@@ -78,8 +78,10 @@ export declare const setQueryParams: (url: string, params: Record<string, string
|
|
|
78
78
|
export declare const removeQueryParams: (url?: string) => string;
|
|
79
79
|
/** Options for checkUrlAvailability */
|
|
80
80
|
export type CheckUrlAvailabilityOptions = {
|
|
81
|
-
/** Request timeout in milliseconds */
|
|
81
|
+
/** Request timeout in milliseconds (default: 5000) */
|
|
82
82
|
timeout?: number;
|
|
83
|
+
/** HTTP status codes below this value are considered successful (default: 400) */
|
|
84
|
+
successStatusBelow?: number;
|
|
83
85
|
/** User-Agent header to send with requests */
|
|
84
86
|
userAgent?: string;
|
|
85
87
|
};
|
package/dist/http/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http/http.ts"],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AAA;CACnB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,KAAK,MAAM,EACX,UAAS,2BAAgC,KACxC,OAAO,CAAC,OAAO,CAwCjB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
1
|
+
import d from "@sindresorhus/slugify";
|
|
2
|
+
const F = (t, e) => {
|
|
3
3
|
const r = e - t + 1;
|
|
4
4
|
return Array.from({ length: r }, (n, s) => s + t);
|
|
5
|
-
},
|
|
5
|
+
}, y = async (t) => new Promise((e) => setTimeout(e, t)), j = ({ key: t, metaKey: e }) => `${e ? "⌘" : ""}${t.toUpperCase()}`, w = (t) => t.replace(/<[^>]*>?/gm, ""), b = (t, e = " ") => t.replace(/\n+/g, e), z = (t, e = 250) => {
|
|
6
6
|
if (!t)
|
|
7
7
|
return null;
|
|
8
|
-
const r =
|
|
8
|
+
const r = b(w(t)), n = r.slice(0, e).trim();
|
|
9
9
|
return n.length < r.length ? `${n}...` : n;
|
|
10
|
-
},
|
|
10
|
+
}, W = (t, e = !1) => d(t, {
|
|
11
11
|
decamelize: e,
|
|
12
12
|
customReplacements: [
|
|
13
13
|
["#", "sharp"],
|
|
14
14
|
["+", "plus"]
|
|
15
15
|
]
|
|
16
|
-
}),
|
|
16
|
+
}), K = (t) => t.length === 25 && t[0] === "c", U = (t) => !!t, J = (t, e = 0) => {
|
|
17
17
|
const r = (t || "").trim();
|
|
18
18
|
if (r.length === 0 || r.length === 1 || r.length === 2)
|
|
19
19
|
return r.toUpperCase();
|
|
20
|
-
const s = r.split(" ").filter(
|
|
20
|
+
const s = r.split(" ").filter(U).map((o) => o.charAt(0).toUpperCase()).join("");
|
|
21
21
|
return e > 0 ? s.slice(0, e) : s;
|
|
22
|
-
},
|
|
22
|
+
}, V = (t) => new Promise((e, r) => {
|
|
23
23
|
const n = new FileReader();
|
|
24
24
|
n.readAsDataURL(t), n.onload = () => e(n.result), n.onerror = (s) => r(s);
|
|
25
|
-
}),
|
|
25
|
+
}), M = (t, e) => {
|
|
26
26
|
const r = [];
|
|
27
27
|
for (let n = 0; n < t.length; n += e)
|
|
28
28
|
r.push(t.slice(n, n + e));
|
|
29
29
|
return r;
|
|
30
|
-
},
|
|
30
|
+
}, H = (t, e, r = !1) => {
|
|
31
31
|
Object.getOwnPropertyDescriptor(
|
|
32
32
|
HTMLInputElement.prototype,
|
|
33
33
|
"value"
|
|
34
34
|
)?.set?.call(t, e), r && t?.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
35
|
-
},
|
|
35
|
+
}, Z = (t, e = 3, r = "and") => t.slice(0, e).join(", ").replace(/, ([^,]*)$/, ` ${r} $1`), G = async (t) => {
|
|
36
36
|
try {
|
|
37
37
|
return { data: await t, error: null };
|
|
38
38
|
} catch (e) {
|
|
39
39
|
return { data: null, error: e };
|
|
40
40
|
}
|
|
41
|
-
},
|
|
41
|
+
}, E = (t) => {
|
|
42
42
|
if (t !== null) {
|
|
43
43
|
if (t?.constructor.name === "Object")
|
|
44
44
|
for (const e in t)
|
|
45
|
-
t[e] =
|
|
45
|
+
t[e] = E(t[e]);
|
|
46
46
|
return t;
|
|
47
47
|
}
|
|
48
|
-
},
|
|
48
|
+
}, Q = (t, e) => e.some((r) => {
|
|
49
49
|
const [n, s] = t.split("/"), [o, c] = r.split("/");
|
|
50
50
|
return n !== o ? !1 : c === "*" ? !0 : s === c;
|
|
51
|
-
}),
|
|
51
|
+
}), S = async (t, e, r) => {
|
|
52
52
|
const { batchSize: n, concurrency: s = n, delay: o = 0 } = r;
|
|
53
53
|
if (t.length === 0) return [];
|
|
54
|
-
const c = [], a =
|
|
54
|
+
const c = [], a = M(t, n);
|
|
55
55
|
for (const [i, u] of a.entries()) {
|
|
56
56
|
console.log(`Processing batch ${i + 1}/${a.length} (${u.length} items)`);
|
|
57
|
-
const
|
|
58
|
-
c.push(...
|
|
57
|
+
const l = await R(u, e, s);
|
|
58
|
+
c.push(...l), o > 0 && i < a.length - 1 && (console.log(`Waiting ${o}ms before next batch...`), await y(o));
|
|
59
59
|
}
|
|
60
60
|
return c;
|
|
61
|
-
},
|
|
61
|
+
}, _ = async (t, e, r) => {
|
|
62
62
|
const { onError: n } = r;
|
|
63
|
-
return
|
|
63
|
+
return S(t, async (o) => {
|
|
64
64
|
try {
|
|
65
65
|
return await e(o);
|
|
66
66
|
} catch (c) {
|
|
@@ -68,7 +68,7 @@ const B = (t, e) => {
|
|
|
68
68
|
return n?.(a, o), a;
|
|
69
69
|
}
|
|
70
70
|
}, r);
|
|
71
|
-
},
|
|
71
|
+
}, R = async (t, e, r) => {
|
|
72
72
|
if (r >= t.length)
|
|
73
73
|
return Promise.all(t.map(e));
|
|
74
74
|
const n = [], s = [];
|
|
@@ -79,42 +79,42 @@ const B = (t, e) => {
|
|
|
79
79
|
s.push(c), s.length >= r && (await Promise.race(s), s.splice(0, s.length - s.filter((a) => a !== c).length));
|
|
80
80
|
}
|
|
81
81
|
return await Promise.all(s), n;
|
|
82
|
-
},
|
|
82
|
+
}, q = (t) => {
|
|
83
83
|
const e = t.replace("#", "").substring(0, 6), r = Number.parseInt(e.substring(0, 2), 16), n = Number.parseInt(e.substring(2, 4), 16), s = Number.parseInt(e.substring(4, 6), 16);
|
|
84
84
|
return r * 0.299 + n * 0.587 + s * 0.114 > 186;
|
|
85
|
-
},
|
|
85
|
+
}, Y = (t) => {
|
|
86
86
|
const e = document.getElementById(t || "");
|
|
87
87
|
if (!e) return;
|
|
88
88
|
const r = window.getComputedStyle(e), n = Number.parseFloat(r.scrollMarginTop), s = Math.floor(window.scrollY + e.getBoundingClientRect().top - n);
|
|
89
89
|
return { id: t, top: s };
|
|
90
|
-
},
|
|
91
|
-
if (
|
|
90
|
+
}, P = (t) => typeof t == "object" && t !== null && "message" in t && typeof t.message == "string", N = (t) => {
|
|
91
|
+
if (P(t)) return t;
|
|
92
92
|
try {
|
|
93
93
|
return new Error(JSON.stringify(t));
|
|
94
94
|
} catch {
|
|
95
95
|
return new Error(String(t));
|
|
96
96
|
}
|
|
97
|
-
},
|
|
97
|
+
}, X = (t) => N(t).message, tt = (t, e) => {
|
|
98
98
|
document.addEventListener(t, e);
|
|
99
|
-
},
|
|
99
|
+
}, et = (t, e) => {
|
|
100
100
|
document.removeEventListener(t, e);
|
|
101
|
-
},
|
|
101
|
+
}, rt = (t, e) => {
|
|
102
102
|
const r = new CustomEvent(t, { detail: e });
|
|
103
103
|
document.dispatchEvent(r);
|
|
104
|
-
},
|
|
104
|
+
}, nt = () => {
|
|
105
105
|
const t = new KeyboardEvent("keydown", { key: "Escape" });
|
|
106
106
|
document.dispatchEvent(t);
|
|
107
|
-
},
|
|
107
|
+
}, st = (t, e = "compact", r = "en-US") => new Intl.NumberFormat(r, { notation: e }).format(t), ot = (t, e = "USD", r = "en-US") => new Intl.NumberFormat(r, {
|
|
108
108
|
style: "currency",
|
|
109
109
|
currency: e
|
|
110
|
-
}).format(t).replace(/\D00(?=\D*$)/, ""),
|
|
110
|
+
}).format(t).replace(/\D00(?=\D*$)/, ""), ct = (t, e = "month") => f(t / (e === "year" ? 12 : 1), 2), f = (t, e = 0) => t.toFixed(e < 0 ? 0 : e).replace(/\.0+$/, ""), at = (t, e = 0) => {
|
|
111
111
|
if (t < 1024) {
|
|
112
112
|
const c = 10 ** e;
|
|
113
113
|
return `${Math.floor(t / 1024 * c) / c} KB`;
|
|
114
114
|
}
|
|
115
115
|
const n = Math.floor(Math.log(t) / Math.log(1024));
|
|
116
|
-
return `${
|
|
117
|
-
},
|
|
116
|
+
return `${f(t / 1024 ** n, e)} ${["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][n]}`;
|
|
117
|
+
}, it = (t) => {
|
|
118
118
|
const [, e] = t.split("/");
|
|
119
119
|
let r;
|
|
120
120
|
switch (e) {
|
|
@@ -124,14 +124,14 @@ const B = (t, e) => {
|
|
|
124
124
|
r = e;
|
|
125
125
|
}
|
|
126
126
|
return r?.toUpperCase();
|
|
127
|
-
},
|
|
128
|
-
if (!t || typeof t != "string" || !
|
|
127
|
+
}, v = /^https?:\/\/(?:www\.)?(?:[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,63}\b|localhost(?::\d+)?|127\.0\.0\.1(?::\d+)?)(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)$/, I = (t) => {
|
|
128
|
+
if (!t || typeof t != "string" || !v.test(t)) return !1;
|
|
129
129
|
try {
|
|
130
130
|
return new URL(t), !0;
|
|
131
131
|
} catch {
|
|
132
132
|
return !1;
|
|
133
133
|
}
|
|
134
|
-
},
|
|
134
|
+
}, T = (t, e) => t ? t.startsWith("http://") || t.startsWith("https://") ? t : `${e !== void 0 ? e ? "https" : "http" : D(t) ? "http" : "https"}://${t}` : "", ut = (t) => t?.replace(/^https?:\/\//, "") ?? "", h = (t) => {
|
|
135
135
|
if (!t) return "";
|
|
136
136
|
let e = t.trim();
|
|
137
137
|
if (e.includes("?") || e.includes("#"))
|
|
@@ -142,39 +142,39 @@ const B = (t, e) => {
|
|
|
142
142
|
return e.length > 1 && e.endsWith("/") ? e.slice(0, -1) : e;
|
|
143
143
|
}
|
|
144
144
|
return e.length > 1 && e.endsWith("/") && (e = e.slice(0, -1)), e;
|
|
145
|
-
},
|
|
145
|
+
}, lt = (t) => {
|
|
146
146
|
try {
|
|
147
147
|
const e = new URL(t);
|
|
148
148
|
return `${e.protocol}//${e.host}`;
|
|
149
149
|
} catch {
|
|
150
150
|
return t;
|
|
151
151
|
}
|
|
152
|
-
},
|
|
152
|
+
}, ht = (t) => {
|
|
153
153
|
try {
|
|
154
|
-
if (!
|
|
154
|
+
if (!I(t)) return t;
|
|
155
155
|
const e = new URL(t).hostname;
|
|
156
156
|
return e.startsWith("www.") ? e.slice(4) : e;
|
|
157
157
|
} catch {
|
|
158
158
|
return t;
|
|
159
159
|
}
|
|
160
|
-
},
|
|
160
|
+
}, mt = (t) => t ? /^https?:\/\//.test(t) : !1, D = (t) => {
|
|
161
161
|
if (!t) return !1;
|
|
162
162
|
try {
|
|
163
|
-
const r = new URL(
|
|
163
|
+
const r = new URL(T(t)).hostname;
|
|
164
164
|
return r === "localhost" || r === "127.0.0.1" || r.endsWith(".localhost");
|
|
165
165
|
} catch {
|
|
166
166
|
return t.includes("localhost") || t.includes("127.0.0.1");
|
|
167
167
|
}
|
|
168
|
-
},
|
|
168
|
+
}, ft = (t, ...e) => {
|
|
169
169
|
if (!t) return "";
|
|
170
|
-
let r =
|
|
170
|
+
let r = h(t);
|
|
171
171
|
for (const n of e) {
|
|
172
172
|
if (!n) continue;
|
|
173
173
|
const s = n.replace(/^\/+|\/+$/g, "");
|
|
174
174
|
s && (r += `/${s}`);
|
|
175
175
|
}
|
|
176
176
|
return r;
|
|
177
|
-
},
|
|
177
|
+
}, O = (t) => {
|
|
178
178
|
try {
|
|
179
179
|
const e = new URL(t), r = {};
|
|
180
180
|
return e.searchParams.forEach((n, s) => {
|
|
@@ -183,7 +183,7 @@ const B = (t, e) => {
|
|
|
183
183
|
} catch {
|
|
184
184
|
return {};
|
|
185
185
|
}
|
|
186
|
-
},
|
|
186
|
+
}, pt = (t, e) => {
|
|
187
187
|
try {
|
|
188
188
|
const r = new URL(t);
|
|
189
189
|
Object.entries(e).forEach(([s, o]) => {
|
|
@@ -194,164 +194,157 @@ const B = (t, e) => {
|
|
|
194
194
|
} catch {
|
|
195
195
|
return t;
|
|
196
196
|
}
|
|
197
|
-
},
|
|
197
|
+
}, gt = (t) => {
|
|
198
198
|
if (!t) return "";
|
|
199
199
|
try {
|
|
200
200
|
const e = new URL(t);
|
|
201
|
-
return e.search = "",
|
|
201
|
+
return e.search = "", h(e.toString());
|
|
202
202
|
} catch {
|
|
203
203
|
const e = t.indexOf("?");
|
|
204
204
|
return e !== -1 ? t.substring(0, e) : t;
|
|
205
205
|
}
|
|
206
|
-
},
|
|
206
|
+
}, dt = async (t, e = {}) => {
|
|
207
207
|
if (!t)
|
|
208
208
|
return !1;
|
|
209
|
-
const {
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
const {
|
|
210
|
+
timeout: r = 5e3,
|
|
211
|
+
successStatusBelow: n = 400,
|
|
212
|
+
userAgent: s = "Mozilla/5.0 (compatible; URLChecker/1.0)"
|
|
213
|
+
} = e, o = h(t), c = async (u) => {
|
|
214
|
+
const l = new AbortController(), m = setTimeout(() => l.abort(), r);
|
|
212
215
|
try {
|
|
213
|
-
const
|
|
214
|
-
method:
|
|
215
|
-
signal:
|
|
216
|
+
const g = await fetch(o, {
|
|
217
|
+
method: u,
|
|
218
|
+
signal: l.signal,
|
|
216
219
|
redirect: "follow",
|
|
217
|
-
headers: { "User-Agent":
|
|
220
|
+
headers: { "User-Agent": s }
|
|
218
221
|
});
|
|
219
|
-
return clearTimeout(
|
|
222
|
+
return clearTimeout(m), g;
|
|
220
223
|
} catch {
|
|
221
|
-
clearTimeout(
|
|
222
|
-
const a = new AbortController(), i = setTimeout(() => a.abort(), r);
|
|
223
|
-
try {
|
|
224
|
-
const u = await fetch(s, {
|
|
225
|
-
method: "GET",
|
|
226
|
-
signal: a.signal,
|
|
227
|
-
redirect: "follow",
|
|
228
|
-
headers: { "User-Agent": n }
|
|
229
|
-
});
|
|
230
|
-
return clearTimeout(i), u.status < 400;
|
|
231
|
-
} catch {
|
|
232
|
-
return clearTimeout(i), !1;
|
|
233
|
-
}
|
|
224
|
+
return clearTimeout(m), null;
|
|
234
225
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
226
|
+
}, a = await c("HEAD");
|
|
227
|
+
if (a && a.status < n)
|
|
228
|
+
return !0;
|
|
229
|
+
const i = await c("GET");
|
|
230
|
+
return i !== null && i.status < n;
|
|
231
|
+
}, yt = (t, e, r) => e !== void 0 && r !== void 0 ? Math.min(Math.max(t, e), r) : e !== void 0 ? Math.max(t, e) : r !== void 0 ? Math.min(t, r) : t, wt = (t) => {
|
|
239
232
|
if (t == null) return;
|
|
240
233
|
const e = Number.parseFloat(t.toString());
|
|
241
234
|
return Number.isNaN(e) ? void 0 : e;
|
|
242
|
-
},
|
|
243
|
-
const r =
|
|
235
|
+
}, bt = (t, e = 2) => {
|
|
236
|
+
const r = 10 ** e;
|
|
244
237
|
return Math.round((t + Number.EPSILON) * r) / r;
|
|
245
|
-
},
|
|
238
|
+
}, Ut = (t = {}) => t.constructor === Object && !Object.entries(t).length, Mt = (t, e) => t in e, Et = (t) => (e, r) => {
|
|
246
239
|
const n = t.indexOf(Object.keys(e)[0] ?? ""), s = t.indexOf(Object.keys(r)[0] ?? "");
|
|
247
240
|
return n === -1 && s === -1 ? 0 : n === -1 ? 1 : s === -1 ? -1 : n - s;
|
|
248
|
-
},
|
|
241
|
+
}, St = (t, e) => Object.keys(t).sort(e).reduce((r, n) => ({ ...r, [n]: t[n] }), {}), Rt = (t, e) => {
|
|
249
242
|
const r = {};
|
|
250
243
|
for (const n of e)
|
|
251
244
|
n in t && (r[n] = t[n]);
|
|
252
245
|
return r;
|
|
253
|
-
},
|
|
254
|
-
const { page: r, ...n } =
|
|
246
|
+
}, $ = (t) => Math.max(t && !Number.isNaN(Number(t)) ? Number.parseInt(t || "1", 10) : 1, 1), Pt = (t, e) => {
|
|
247
|
+
const { page: r, ...n } = O(t), o = ($(r) - 1) * e;
|
|
255
248
|
return { take: e, skip: o, ...n };
|
|
256
|
-
},
|
|
249
|
+
}, Nt = (t, e, r) => (t.set("page", r.toString()), `${e}?${t.toString()}`), vt = (t) => {
|
|
257
250
|
try {
|
|
258
251
|
return JSON.parse(t);
|
|
259
252
|
} catch {
|
|
260
253
|
return t;
|
|
261
254
|
}
|
|
262
|
-
},
|
|
255
|
+
}, It = (t) => typeof t == "object" ? JSON.stringify(t) : t, Tt = () => Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0"), Dt = (t = 16) => {
|
|
263
256
|
const e = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
264
257
|
return Array.from({ length: t }, () => e[Math.floor(Math.random() * e.length)]).join("");
|
|
265
|
-
},
|
|
258
|
+
}, Ot = (t, e) => Math.floor(Math.random() * (e - t + 1)) + t, $t = (t) => Array.from({ length: t }, () => Math.floor(Math.random() * 10)).join(""), Lt = (t) => {
|
|
266
259
|
const e = Math.floor(Math.random() * t.length);
|
|
267
260
|
return t[e];
|
|
268
|
-
},
|
|
261
|
+
}, kt = (t) => {
|
|
269
262
|
const e = Object.keys(t), r = e[Math.floor(e.length * Math.random())];
|
|
270
263
|
return t[r];
|
|
271
|
-
}, Ct = (t) => typeof t != "string" ? "" : t.length === 0 ? t : t[0]?.toUpperCase() + t.slice(1),
|
|
264
|
+
}, Ct = (t) => typeof t != "string" ? "" : t.length === 0 ? t : t[0]?.toUpperCase() + t.slice(1), Bt = (t) => typeof t != "string" ? "" : t.length === 0 ? t : t[0]?.toLowerCase() + t.slice(1), p = (t, e) => new Intl.DateTimeFormat(t, { dateStyle: e }), L = (t, e) => new Intl.DateTimeFormat(t, { timeStyle: e }), k = (t, e, r) => new Intl.DateTimeFormat(t, { dateStyle: e, timeStyle: r }), C = (t, e = "medium", r = "en-US") => p(r, e).format(new Date(t)), B = (t, e = "short", r = "en-US") => L(r, e).format(new Date(t)), x = (t, e = "medium", r = "short", n = "en-US") => k(n, e, r).format(new Date(t)), xt = (t, e, r = "medium", n = "short", s = "en-US") => {
|
|
272
265
|
switch (e) {
|
|
273
266
|
case "date":
|
|
274
267
|
return C(t, r, s);
|
|
275
268
|
case "time":
|
|
276
|
-
return
|
|
269
|
+
return B(t, n, s);
|
|
277
270
|
default:
|
|
278
|
-
return
|
|
271
|
+
return x(t, r, n, s);
|
|
279
272
|
}
|
|
280
|
-
}, At = (t, e, r = "medium", n = "en-US") =>
|
|
273
|
+
}, At = (t, e, r = "medium", n = "en-US") => p(n, r).formatRange(new Date(t), new Date(e)), Ft = (t, e = 265) => t ? Math.ceil(t.trim().split(/\s+/).length / e) : 0;
|
|
281
274
|
export {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
275
|
+
T as addProtocol,
|
|
276
|
+
dt as checkUrlAvailability,
|
|
277
|
+
b as convertNewlines,
|
|
278
|
+
at as formatBytes,
|
|
279
|
+
ot as formatCurrency,
|
|
287
280
|
C as formatDate,
|
|
288
|
-
|
|
281
|
+
xt as formatDateOrTime,
|
|
289
282
|
At as formatDateRange,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
283
|
+
x as formatDateTime,
|
|
284
|
+
ct as formatIntervalAmount,
|
|
285
|
+
it as formatMimeType,
|
|
286
|
+
st as formatNumber,
|
|
287
|
+
B as formatTime,
|
|
288
|
+
f as formatToDecimals,
|
|
289
|
+
lt as getBaseUrl,
|
|
290
|
+
$ as getCurrentPage,
|
|
291
|
+
ht as getDomain,
|
|
292
|
+
Y as getElementPosition,
|
|
293
|
+
X as getErrorMessage,
|
|
294
|
+
z as getExcerpt,
|
|
295
|
+
J as getInitials,
|
|
296
|
+
Nt as getPageLink,
|
|
297
|
+
Pt as getPageParams,
|
|
298
|
+
O as getQueryParams,
|
|
299
|
+
Tt as getRandomColor,
|
|
300
|
+
$t as getRandomDigits,
|
|
301
|
+
Lt as getRandomElement,
|
|
302
|
+
Ot as getRandomNumber,
|
|
303
|
+
kt as getRandomProperty,
|
|
304
|
+
Dt as getRandomString,
|
|
305
|
+
Ft as getReadTime,
|
|
306
|
+
j as getShortcutLabel,
|
|
307
|
+
K as isCuid,
|
|
308
|
+
Ut as isEmptyObject,
|
|
309
|
+
P as isErrorWithMessage,
|
|
310
|
+
mt as isExternalUrl,
|
|
311
|
+
Mt as isKeyInObject,
|
|
312
|
+
q as isLightColor,
|
|
313
|
+
D as isLocalhostUrl,
|
|
314
|
+
Q as isMimeTypeMatch,
|
|
315
|
+
U as isTruthy,
|
|
316
|
+
I as isValidUrl,
|
|
317
|
+
Z as joinAsSentence,
|
|
318
|
+
ft as joinUrlPaths,
|
|
319
|
+
yt as keepNumberInRange,
|
|
320
|
+
Bt as lcFirst,
|
|
321
|
+
vt as maybeParseJson,
|
|
322
|
+
It as maybeStringifyJson,
|
|
323
|
+
h as normalizeUrl,
|
|
324
|
+
E as nullsToUndefined,
|
|
325
|
+
wt as parseNumericValue,
|
|
326
|
+
Rt as pickFromObject,
|
|
327
|
+
bt as preciseRound,
|
|
328
|
+
S as processBatch,
|
|
329
|
+
_ as processBatchWithErrorHandling,
|
|
330
|
+
rt as publish,
|
|
331
|
+
nt as publishEscape,
|
|
332
|
+
F as range,
|
|
333
|
+
ut as removeProtocol,
|
|
334
|
+
gt as removeQueryParams,
|
|
335
|
+
H as setInputValue,
|
|
336
|
+
pt as setQueryParams,
|
|
337
|
+
y as sleep,
|
|
338
|
+
W as slugify,
|
|
339
|
+
St as sortObject,
|
|
340
|
+
Et as sortObjectKeys,
|
|
341
|
+
M as splitArrayIntoChunks,
|
|
342
|
+
w as stripHtml,
|
|
343
|
+
tt as subscribe,
|
|
344
|
+
V as toBase64,
|
|
345
|
+
N as toErrorWithMessage,
|
|
346
|
+
G as tryCatch,
|
|
354
347
|
Ct as ucFirst,
|
|
355
|
-
|
|
348
|
+
et as unsubscribe
|
|
356
349
|
};
|
|
357
350
|
//# sourceMappingURL=index.js.map
|