@ztimson/utils 0.2.4 → 0.4.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/dist/aset.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/objects.d.ts +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.mjs +353 -301
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
package/dist/utils.mjs
CHANGED
|
@@ -1,189 +1,239 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
1
|
+
var U = Object.defineProperty;
|
|
2
|
+
var Y = (n, e, t) => e in n ? U(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var l = (n, e, t) => (Y(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
function P(n, e = !1) {
|
|
5
|
+
if (n == null)
|
|
6
6
|
throw new Error("Cannot clean a NULL value");
|
|
7
|
-
return Array.isArray(
|
|
8
|
-
(
|
|
9
|
-
}),
|
|
7
|
+
return Array.isArray(n) ? n = n.filter((t) => t != null) : Object.entries(n).forEach(([t, r]) => {
|
|
8
|
+
(e && r === void 0 || !e && r == null) && delete n[t];
|
|
9
|
+
}), n;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return JSON.parse(JSON.stringify(
|
|
11
|
+
function _(n) {
|
|
12
|
+
return JSON.parse(JSON.stringify(n));
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
if (!(
|
|
16
|
-
return
|
|
14
|
+
function m(n, e, t) {
|
|
15
|
+
if (!(n == null || !e))
|
|
16
|
+
return e.split(/[.[\]]/g).filter((r) => r.length).reduce((r, o, s, i) => {
|
|
17
17
|
if ((o[0] == '"' || o[0] == "'") && (o = o.slice(1, -1)), !(r != null && r.hasOwnProperty(o))) {
|
|
18
18
|
if (t == null)
|
|
19
19
|
return;
|
|
20
20
|
r[o] = {};
|
|
21
21
|
}
|
|
22
|
-
return t !== void 0 && s ==
|
|
23
|
-
},
|
|
24
|
-
}
|
|
25
|
-
function
|
|
26
|
-
if (typeof
|
|
27
|
-
for (const r of Object.keys(
|
|
28
|
-
const o =
|
|
29
|
-
typeof
|
|
22
|
+
return t !== void 0 && s == i.length - 1 ? r[o] = t : r[o];
|
|
23
|
+
}, n);
|
|
24
|
+
}
|
|
25
|
+
function H(n, e, t = {}) {
|
|
26
|
+
if (typeof n == "object" && !Array.isArray(n)) {
|
|
27
|
+
for (const r of Object.keys(n)) {
|
|
28
|
+
const o = e ? e + "." + r : r;
|
|
29
|
+
typeof n[r] == "object" ? H(n[r], o, t) : t[o] = n[r];
|
|
30
30
|
}
|
|
31
31
|
return t;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
if (
|
|
34
|
+
function L(n, e, t = !1) {
|
|
35
|
+
if (n == null)
|
|
36
36
|
return t;
|
|
37
|
-
if (Array.isArray(
|
|
38
|
-
return
|
|
39
|
-
const r = typeof
|
|
40
|
-
return r != typeof
|
|
37
|
+
if (Array.isArray(e))
|
|
38
|
+
return e.findIndex((o, s) => !L(n[s], e[s], t)) == -1;
|
|
39
|
+
const r = typeof e;
|
|
40
|
+
return r != typeof n ? !1 : r == "object" ? Object.keys(e).find((o) => !L(n[o], e[o], t)) == null : r == "function" ? n.toString() == e.toString() : n == e;
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const t = typeof
|
|
44
|
-
return t != "object" ||
|
|
42
|
+
function B(n, e) {
|
|
43
|
+
const t = typeof n, r = typeof e;
|
|
44
|
+
return t != "object" || n == null || r != "object" || e == null ? t == "function" && r == "function" ? n.toString() == e.toString() : n === e : Object.keys(n).length != Object.keys(e).length ? !1 : Object.keys(n).every((s) => B(n[s], e[s]));
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
46
|
+
function tt(n, e) {
|
|
47
|
+
e.forEach((t) => {
|
|
48
48
|
Object.getOwnPropertyNames(t.prototype).forEach((r) => {
|
|
49
49
|
Object.defineProperty(
|
|
50
|
-
|
|
50
|
+
n.prototype,
|
|
51
51
|
r,
|
|
52
52
|
Object.getOwnPropertyDescriptor(t.prototype, r) || /* @__PURE__ */ Object.create(null)
|
|
53
53
|
);
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
57
|
+
function et(n, e) {
|
|
58
|
+
let t = [];
|
|
59
|
+
return JSON.parse(JSON.stringify(n, (r, o) => {
|
|
60
|
+
if (typeof o == "object" && o !== null) {
|
|
61
|
+
if (t.includes(o))
|
|
62
|
+
return;
|
|
63
|
+
t.push(o);
|
|
64
|
+
}
|
|
65
|
+
return o;
|
|
66
|
+
}, e));
|
|
67
|
+
}
|
|
68
|
+
function nt(n, e) {
|
|
69
|
+
return n.indexOf(e) === -1 && n.push(e), n;
|
|
59
70
|
}
|
|
60
|
-
function
|
|
61
|
-
return
|
|
62
|
-
...
|
|
63
|
-
...
|
|
71
|
+
function rt(n, e) {
|
|
72
|
+
return q([
|
|
73
|
+
...n.filter((t) => !e.includes((r) => B(t, r))),
|
|
74
|
+
...e.filter((t) => !n.includes((r) => B(t, r)))
|
|
64
75
|
]);
|
|
65
76
|
}
|
|
66
|
-
function
|
|
67
|
-
return function(
|
|
68
|
-
const r =
|
|
77
|
+
function ot(n) {
|
|
78
|
+
return function(e, t) {
|
|
79
|
+
const r = m(e, n), o = m(t, n);
|
|
69
80
|
return typeof r != "string" || typeof o != "string" ? 1 : r.toLowerCase().localeCompare(o.toLowerCase());
|
|
70
81
|
};
|
|
71
82
|
}
|
|
72
|
-
function
|
|
73
|
-
return
|
|
83
|
+
function W(n, e = []) {
|
|
84
|
+
return n.forEach((t) => Array.isArray(t) ? W(t, e) : e.push(t)), e;
|
|
74
85
|
}
|
|
75
|
-
function
|
|
86
|
+
function st(n, e = !1) {
|
|
76
87
|
return function(t, r) {
|
|
77
|
-
const o =
|
|
78
|
-
return typeof o == "number" && typeof s == "number" ? (
|
|
88
|
+
const o = m(t, n), s = m(r, n);
|
|
89
|
+
return typeof o == "number" && typeof s == "number" ? (e ? -1 : 1) * (o - s) : o > s ? e ? -1 : 1 : o < s ? e ? 1 : -1 : 0;
|
|
79
90
|
};
|
|
80
91
|
}
|
|
81
|
-
function
|
|
82
|
-
return (t) =>
|
|
92
|
+
function it(n, e) {
|
|
93
|
+
return (t) => B(t[n], e);
|
|
83
94
|
}
|
|
84
|
-
function
|
|
85
|
-
for (let
|
|
86
|
-
|
|
87
|
-
return
|
|
95
|
+
function q(n) {
|
|
96
|
+
for (let e = n.length - 1; e >= 0; e--)
|
|
97
|
+
n.slice(0, e).find((t) => B(t, n[e])) && n.splice(e, 1);
|
|
98
|
+
return n;
|
|
99
|
+
}
|
|
100
|
+
function ct(n) {
|
|
101
|
+
return Array.isArray(n) ? n : [n];
|
|
88
102
|
}
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
class w extends Array {
|
|
104
|
+
get size() {
|
|
105
|
+
return this.length;
|
|
106
|
+
}
|
|
107
|
+
constructor(e = []) {
|
|
108
|
+
super(), e != null && e.forEach && e.forEach((t) => this.add(t));
|
|
109
|
+
}
|
|
110
|
+
add(e) {
|
|
111
|
+
this.has(e) || this.push(e);
|
|
112
|
+
}
|
|
113
|
+
delete(e) {
|
|
114
|
+
const t = this.indexOf(e);
|
|
115
|
+
t != -1 && this.slice(t, 1);
|
|
116
|
+
}
|
|
117
|
+
difference(e) {
|
|
118
|
+
return new w(this.reduce((t, r) => (e.has(r) || t.push(r), t), []));
|
|
119
|
+
}
|
|
120
|
+
has(e) {
|
|
121
|
+
return this.indexOf(e) != -1;
|
|
122
|
+
}
|
|
123
|
+
intersection(e) {
|
|
124
|
+
return new w(this.reduce((t, r) => (e.has(r) && t.push(r), t), []));
|
|
125
|
+
}
|
|
126
|
+
isDisjointFrom(e) {
|
|
127
|
+
return this.intersection(e).size == 0;
|
|
128
|
+
}
|
|
129
|
+
isSubsetOf(e) {
|
|
130
|
+
return this.findIndex((t) => !e.has(t)) == -1;
|
|
131
|
+
}
|
|
132
|
+
isSuperset(e) {
|
|
133
|
+
return e.findIndex((t) => !this.has(t)) == -1;
|
|
134
|
+
}
|
|
135
|
+
symmetricDifference(e) {
|
|
136
|
+
return new w([...this.difference(e), ...e.difference(this)]);
|
|
137
|
+
}
|
|
138
|
+
union(e) {
|
|
139
|
+
return new w([...this, ...e]);
|
|
140
|
+
}
|
|
91
141
|
}
|
|
92
|
-
class
|
|
142
|
+
class $ {
|
|
93
143
|
constructor() {
|
|
94
|
-
|
|
144
|
+
l(this, "listeners", {});
|
|
95
145
|
}
|
|
96
|
-
static emit(
|
|
97
|
-
(this.listeners["*"] || []).forEach((r) => r(
|
|
146
|
+
static emit(e, ...t) {
|
|
147
|
+
(this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e.toString()] || []).forEach((r) => r(...t));
|
|
98
148
|
}
|
|
99
|
-
static off(
|
|
100
|
-
const r =
|
|
149
|
+
static off(e, t) {
|
|
150
|
+
const r = e.toString();
|
|
101
151
|
this.listeners[r] = (this.listeners[r] || []).filter((o) => o === t);
|
|
102
152
|
}
|
|
103
|
-
static on(
|
|
153
|
+
static on(e, t) {
|
|
104
154
|
var o;
|
|
105
|
-
const r =
|
|
106
|
-
return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(t), () => this.off(
|
|
155
|
+
const r = e.toString();
|
|
156
|
+
return this.listeners[r] || (this.listeners[r] = []), (o = this.listeners[r]) == null || o.push(t), () => this.off(e, t);
|
|
107
157
|
}
|
|
108
|
-
static once(
|
|
158
|
+
static once(e, t) {
|
|
109
159
|
return new Promise((r) => {
|
|
110
|
-
const o = this.on(
|
|
160
|
+
const o = this.on(e, (...s) => {
|
|
111
161
|
r(s.length == 1 ? s[0] : s), t && t(...s), o();
|
|
112
162
|
});
|
|
113
163
|
});
|
|
114
164
|
}
|
|
115
|
-
emit(
|
|
116
|
-
(this.listeners["*"] || []).forEach((r) => r(
|
|
165
|
+
emit(e, ...t) {
|
|
166
|
+
(this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e] || []).forEach((r) => r(...t));
|
|
117
167
|
}
|
|
118
|
-
off(
|
|
119
|
-
this.listeners[
|
|
168
|
+
off(e, t) {
|
|
169
|
+
this.listeners[e] = (this.listeners[e] || []).filter((r) => r === t);
|
|
120
170
|
}
|
|
121
|
-
on(
|
|
171
|
+
on(e, t) {
|
|
122
172
|
var r;
|
|
123
|
-
return this.listeners[
|
|
173
|
+
return this.listeners[e] || (this.listeners[e] = []), (r = this.listeners[e]) == null || r.push(t), () => this.off(e, t);
|
|
124
174
|
}
|
|
125
|
-
once(
|
|
175
|
+
once(e, t) {
|
|
126
176
|
return new Promise((r) => {
|
|
127
|
-
const o = this.on(
|
|
177
|
+
const o = this.on(e, (...s) => {
|
|
128
178
|
r(s.length == 1 ? s[0] : s), t && t(...s), o();
|
|
129
179
|
});
|
|
130
180
|
});
|
|
131
181
|
}
|
|
132
182
|
}
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
constructor(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.opts =
|
|
183
|
+
l($, "listeners", {});
|
|
184
|
+
const d = class d {
|
|
185
|
+
constructor(e = {}) {
|
|
186
|
+
l(this, "interceptors", {});
|
|
187
|
+
l(this, "headers", {});
|
|
188
|
+
this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => d.addInterceptor(t));
|
|
139
189
|
}
|
|
140
|
-
static addInterceptor(
|
|
141
|
-
const t = Object.keys(
|
|
142
|
-
return
|
|
143
|
-
|
|
190
|
+
static addInterceptor(e) {
|
|
191
|
+
const t = Object.keys(d.interceptors).length.toString();
|
|
192
|
+
return d.interceptors[t] = e, () => {
|
|
193
|
+
d.interceptors[t] = null;
|
|
144
194
|
};
|
|
145
195
|
}
|
|
146
|
-
addInterceptor(
|
|
196
|
+
addInterceptor(e) {
|
|
147
197
|
const t = Object.keys(this.interceptors).length.toString();
|
|
148
|
-
return this.interceptors[t] =
|
|
198
|
+
return this.interceptors[t] = e, () => {
|
|
149
199
|
this.interceptors[t] = null;
|
|
150
200
|
};
|
|
151
201
|
}
|
|
152
|
-
async request(
|
|
202
|
+
async request(e = {}) {
|
|
153
203
|
var o, s;
|
|
154
|
-
if (!this.opts.url && !
|
|
204
|
+
if (!this.opts.url && !e.url)
|
|
155
205
|
throw new Error("URL needs to be set");
|
|
156
|
-
const t = ((o =
|
|
157
|
-
"Content-Type":
|
|
158
|
-
...
|
|
206
|
+
const t = ((o = e.url) != null && o.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1"), r = P({
|
|
207
|
+
"Content-Type": e.body && !(e.body instanceof FormData) ? "application/json" : void 0,
|
|
208
|
+
...d.headers,
|
|
159
209
|
...this.headers,
|
|
160
|
-
...
|
|
210
|
+
...e.headers
|
|
161
211
|
});
|
|
162
212
|
return fetch(t, {
|
|
163
213
|
headers: r,
|
|
164
|
-
method:
|
|
165
|
-
body: (s = r["Content-Type"]) != null && s.startsWith("application/json") &&
|
|
166
|
-
}).then(async (
|
|
167
|
-
var
|
|
168
|
-
for (let
|
|
169
|
-
await new Promise((
|
|
170
|
-
if (!
|
|
171
|
-
throw new Error(
|
|
172
|
-
return (
|
|
214
|
+
method: e.method || (e.body ? "POST" : "GET"),
|
|
215
|
+
body: (s = r["Content-Type"]) != null && s.startsWith("application/json") && e.body ? JSON.stringify(e.body) : e.body
|
|
216
|
+
}).then(async (i) => {
|
|
217
|
+
var y, E;
|
|
218
|
+
for (let S of [...Object.values(d.interceptors), ...Object.values(this.interceptors)])
|
|
219
|
+
await new Promise((T) => S(i, () => T()));
|
|
220
|
+
if (!i.ok)
|
|
221
|
+
throw new Error(i.statusText);
|
|
222
|
+
return (y = i.headers.get("Content-Type")) != null && y.startsWith("application/json") ? await i.json() : (E = i.headers.get("Content-Type")) != null && E.startsWith("text/plain") ? await i.text() : i;
|
|
173
223
|
});
|
|
174
224
|
}
|
|
175
225
|
};
|
|
176
|
-
|
|
177
|
-
let
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
return
|
|
181
|
-
throw
|
|
226
|
+
l(d, "interceptors", {}), l(d, "headers", {});
|
|
227
|
+
let R = d;
|
|
228
|
+
R.addInterceptor((n, e) => {
|
|
229
|
+
if (n.status == 200)
|
|
230
|
+
return e();
|
|
231
|
+
throw n.status == 400 ? new D(n.statusText) : n.status == 401 ? new G(n.statusText) : n.status == 403 ? new k(n.statusText) : n.status == 404 ? new j(n.statusText) : n.status == 500 ? new M(n.statusText) : new p(n.statusText, n.status);
|
|
182
232
|
});
|
|
183
|
-
class
|
|
233
|
+
class p extends Error {
|
|
184
234
|
constructor(t, r) {
|
|
185
235
|
super(t);
|
|
186
|
-
|
|
236
|
+
l(this, "_code");
|
|
187
237
|
r != null && (this._code = r);
|
|
188
238
|
}
|
|
189
239
|
get code() {
|
|
@@ -207,53 +257,53 @@ class E extends Error {
|
|
|
207
257
|
return this.message || super.toString();
|
|
208
258
|
}
|
|
209
259
|
}
|
|
210
|
-
|
|
211
|
-
class
|
|
212
|
-
constructor(
|
|
213
|
-
super(
|
|
260
|
+
l(p, "code", 500);
|
|
261
|
+
class D extends p {
|
|
262
|
+
constructor(e = "Bad Request") {
|
|
263
|
+
super(e);
|
|
214
264
|
}
|
|
215
|
-
static instanceof(
|
|
216
|
-
return
|
|
265
|
+
static instanceof(e) {
|
|
266
|
+
return e.constructor.code == this.code;
|
|
217
267
|
}
|
|
218
268
|
}
|
|
219
|
-
|
|
220
|
-
class
|
|
221
|
-
constructor(
|
|
222
|
-
super(
|
|
269
|
+
l(D, "code", 400);
|
|
270
|
+
class G extends p {
|
|
271
|
+
constructor(e = "Unauthorized") {
|
|
272
|
+
super(e);
|
|
223
273
|
}
|
|
224
|
-
static instanceof(
|
|
225
|
-
return
|
|
274
|
+
static instanceof(e) {
|
|
275
|
+
return e.constructor.code == this.code;
|
|
226
276
|
}
|
|
227
277
|
}
|
|
228
|
-
|
|
229
|
-
class
|
|
230
|
-
constructor(
|
|
231
|
-
super(
|
|
278
|
+
l(G, "code", 401);
|
|
279
|
+
class k extends p {
|
|
280
|
+
constructor(e = "Forbidden") {
|
|
281
|
+
super(e);
|
|
232
282
|
}
|
|
233
|
-
static instanceof(
|
|
234
|
-
return
|
|
283
|
+
static instanceof(e) {
|
|
284
|
+
return e.constructor.code == this.code;
|
|
235
285
|
}
|
|
236
286
|
}
|
|
237
|
-
|
|
238
|
-
class
|
|
239
|
-
constructor(
|
|
240
|
-
super(
|
|
287
|
+
l(k, "code", 403);
|
|
288
|
+
class j extends p {
|
|
289
|
+
constructor(e = "Not Found") {
|
|
290
|
+
super(e);
|
|
241
291
|
}
|
|
242
|
-
static instanceof(
|
|
243
|
-
return
|
|
292
|
+
static instanceof(e) {
|
|
293
|
+
return e.constructor.code == this.code;
|
|
244
294
|
}
|
|
245
295
|
}
|
|
246
|
-
|
|
247
|
-
class
|
|
248
|
-
constructor(
|
|
249
|
-
super(
|
|
296
|
+
l(j, "code", 404);
|
|
297
|
+
class M extends p {
|
|
298
|
+
constructor(e = "Internal Server Error") {
|
|
299
|
+
super(e);
|
|
250
300
|
}
|
|
251
|
-
static instanceof(
|
|
252
|
-
return
|
|
301
|
+
static instanceof(e) {
|
|
302
|
+
return e.constructor.code == this.code;
|
|
253
303
|
}
|
|
254
304
|
}
|
|
255
|
-
|
|
256
|
-
const
|
|
305
|
+
l(M, "code", 500);
|
|
306
|
+
const x = {
|
|
257
307
|
CLEAR: "\x1B[0m",
|
|
258
308
|
BRIGHT: "\x1B[1m",
|
|
259
309
|
DIM: "\x1B[2m",
|
|
@@ -278,7 +328,7 @@ const w = {
|
|
|
278
328
|
LIGHT_MAGENTA: "\x1B[95m",
|
|
279
329
|
LIGHT_CYAN: "\x1B[96m",
|
|
280
330
|
WHITE: "\x1B[97m"
|
|
281
|
-
},
|
|
331
|
+
}, ut = {
|
|
282
332
|
BLACK: "\x1B[40m",
|
|
283
333
|
RED: "\x1B[41m",
|
|
284
334
|
GREEN: "\x1B[42m",
|
|
@@ -289,188 +339,188 @@ const w = {
|
|
|
289
339
|
WHITE: "\x1B[47m",
|
|
290
340
|
GREY: "\x1B[100m"
|
|
291
341
|
};
|
|
292
|
-
var
|
|
293
|
-
const f = class f extends
|
|
294
|
-
constructor(
|
|
295
|
-
super(), this.namespace =
|
|
296
|
-
}
|
|
297
|
-
pad(
|
|
298
|
-
const s =
|
|
299
|
-
if (
|
|
342
|
+
var F = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(F || {});
|
|
343
|
+
const f = class f extends $ {
|
|
344
|
+
constructor(e) {
|
|
345
|
+
super(), this.namespace = e;
|
|
346
|
+
}
|
|
347
|
+
pad(e, t, r, o = !1) {
|
|
348
|
+
const s = e.toString(), i = t - s.length;
|
|
349
|
+
if (i <= 0)
|
|
300
350
|
return s;
|
|
301
|
-
const
|
|
302
|
-
return o ? s +
|
|
351
|
+
const y = Array(~~(i / r.length)).fill(r).join("");
|
|
352
|
+
return o ? s + y : y + s;
|
|
303
353
|
}
|
|
304
|
-
format(...
|
|
354
|
+
format(...e) {
|
|
305
355
|
const t = /* @__PURE__ */ new Date();
|
|
306
|
-
return `${`${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()} ${this.pad(t.getHours().toString(), 2, "0")}:${this.pad(t.getMinutes().toString(), 2, "0")}:${this.pad(t.getSeconds().toString(), 2, "0")}.${this.pad(t.getMilliseconds().toString(), 3, "0", !0)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${
|
|
356
|
+
return `${`${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()} ${this.pad(t.getHours().toString(), 2, "0")}:${this.pad(t.getMinutes().toString(), 2, "0")}:${this.pad(t.getSeconds().toString(), 2, "0")}.${this.pad(t.getMilliseconds().toString(), 3, "0", !0)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${e.join(" ")}`;
|
|
307
357
|
}
|
|
308
|
-
debug(...
|
|
358
|
+
debug(...e) {
|
|
309
359
|
if (f.LOG_LEVEL < 4)
|
|
310
360
|
return;
|
|
311
|
-
const t = this.format(...
|
|
312
|
-
f.emit(4, t), console.debug(A.LIGHT_GREY + t +
|
|
361
|
+
const t = this.format(...e);
|
|
362
|
+
f.emit(4, t), console.debug(A.LIGHT_GREY + t + x.CLEAR);
|
|
313
363
|
}
|
|
314
|
-
log(...
|
|
364
|
+
log(...e) {
|
|
315
365
|
if (f.LOG_LEVEL < 3)
|
|
316
366
|
return;
|
|
317
|
-
const t = this.format(...
|
|
318
|
-
f.emit(3, t), console.log(
|
|
367
|
+
const t = this.format(...e);
|
|
368
|
+
f.emit(3, t), console.log(x.CLEAR + t);
|
|
319
369
|
}
|
|
320
|
-
info(...
|
|
370
|
+
info(...e) {
|
|
321
371
|
if (f.LOG_LEVEL < 2)
|
|
322
372
|
return;
|
|
323
|
-
const t = this.format(...
|
|
324
|
-
f.emit(2, t), console.info(A.BLUE + t +
|
|
373
|
+
const t = this.format(...e);
|
|
374
|
+
f.emit(2, t), console.info(A.BLUE + t + x.CLEAR);
|
|
325
375
|
}
|
|
326
|
-
warn(...
|
|
376
|
+
warn(...e) {
|
|
327
377
|
if (f.LOG_LEVEL < 1)
|
|
328
378
|
return;
|
|
329
|
-
const t = this.format(...
|
|
330
|
-
f.emit(1, t), console.warn(A.YELLOW + t +
|
|
379
|
+
const t = this.format(...e);
|
|
380
|
+
f.emit(1, t), console.warn(A.YELLOW + t + x.CLEAR);
|
|
331
381
|
}
|
|
332
|
-
error(...
|
|
382
|
+
error(...e) {
|
|
333
383
|
if (f.LOG_LEVEL < 0)
|
|
334
384
|
return;
|
|
335
|
-
const t = this.format(...
|
|
336
|
-
f.emit(0, t), console.error(A.RED + t +
|
|
385
|
+
const t = this.format(...e);
|
|
386
|
+
f.emit(0, t), console.error(A.RED + t + x.CLEAR);
|
|
337
387
|
}
|
|
338
388
|
};
|
|
339
|
-
|
|
340
|
-
let
|
|
341
|
-
function
|
|
342
|
-
return
|
|
343
|
-
}
|
|
344
|
-
function
|
|
345
|
-
return Array(
|
|
346
|
-
}
|
|
347
|
-
const C = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
348
|
-
function
|
|
349
|
-
const
|
|
350
|
-
if (!
|
|
351
|
-
throw new Error(`Number cannot be parsed: ${
|
|
352
|
-
return `${
|
|
353
|
-
}
|
|
354
|
-
function
|
|
355
|
-
return `${
|
|
356
|
-
}
|
|
357
|
-
function
|
|
358
|
-
const o =
|
|
389
|
+
l(f, "LOG_LEVEL", 4);
|
|
390
|
+
let b = f;
|
|
391
|
+
function at(n, e) {
|
|
392
|
+
return n.length - n.replaceAll(e, "").length;
|
|
393
|
+
}
|
|
394
|
+
function ht(n) {
|
|
395
|
+
return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
|
|
396
|
+
}
|
|
397
|
+
const C = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", N = "0123456789", I = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", z = C + N + I;
|
|
398
|
+
function lt(n) {
|
|
399
|
+
const e = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
|
|
400
|
+
if (!e)
|
|
401
|
+
throw new Error(`Number cannot be parsed: ${n}`);
|
|
402
|
+
return `${e[1] ?? ""} (${e[2]}) ${e[3]}-${e[4]}`.trim();
|
|
403
|
+
}
|
|
404
|
+
function ft(n, e, t) {
|
|
405
|
+
return `${n.slice(0, t)}${e}${n.slice(t + 1)}`;
|
|
406
|
+
}
|
|
407
|
+
function dt(n, e, t, r = !0) {
|
|
408
|
+
const o = n.toString(), s = e - o.length;
|
|
359
409
|
if (s <= 0)
|
|
360
410
|
return o;
|
|
361
|
-
const
|
|
362
|
-
return r ?
|
|
411
|
+
const i = Array(~~(s / t.length)).fill(t).join("");
|
|
412
|
+
return r ? i + o : o + i;
|
|
363
413
|
}
|
|
364
|
-
function
|
|
365
|
-
return Array(
|
|
366
|
-
const t = ~~(Math.random() *
|
|
367
|
-
return
|
|
414
|
+
function yt(n, e = z) {
|
|
415
|
+
return Array(n).fill(null).map(() => {
|
|
416
|
+
const t = ~~(Math.random() * e.length);
|
|
417
|
+
return e[t];
|
|
368
418
|
}).join("");
|
|
369
419
|
}
|
|
370
|
-
function
|
|
371
|
-
if (!
|
|
420
|
+
function gt(n, e = !1, t = !1, r = !1) {
|
|
421
|
+
if (!e && !t && !r)
|
|
372
422
|
throw new Error("Must enable at least one: letters, numbers, symbols");
|
|
373
|
-
return Array(
|
|
423
|
+
return Array(n).fill(null).map(() => {
|
|
374
424
|
let o;
|
|
375
425
|
do {
|
|
376
426
|
const s = ~~(Math.random() * 3);
|
|
377
|
-
|
|
427
|
+
e && s == 0 ? o = C[~~(Math.random() * C.length)] : t && s == 1 ? o = N[~~(Math.random() * N.length)] : r && s == 2 && (o = I[~~(Math.random() * I.length)]);
|
|
378
428
|
} while (!o);
|
|
379
429
|
return o;
|
|
380
430
|
}).join("");
|
|
381
431
|
}
|
|
382
|
-
function
|
|
383
|
-
if (typeof
|
|
432
|
+
function pt(n, e) {
|
|
433
|
+
if (typeof e == "string" && (e = new RegExp(e, "g")), !e.global)
|
|
384
434
|
throw new TypeError("Regular expression must be global.");
|
|
385
435
|
let t = [], r;
|
|
386
|
-
for (; (r =
|
|
436
|
+
for (; (r = e.exec(n)) !== null; )
|
|
387
437
|
t.push(r);
|
|
388
438
|
return t;
|
|
389
439
|
}
|
|
390
|
-
function
|
|
391
|
-
var
|
|
392
|
-
return
|
|
440
|
+
function J(n) {
|
|
441
|
+
var e = v(V(Z(K(n), 8 * n.length)));
|
|
442
|
+
return e.toLowerCase();
|
|
393
443
|
}
|
|
394
|
-
function
|
|
395
|
-
for (var
|
|
396
|
-
|
|
444
|
+
function v(n) {
|
|
445
|
+
for (var e, t = "0123456789ABCDEF", r = "", o = 0; o < n.length; o++)
|
|
446
|
+
e = n.charCodeAt(o), r += t.charAt(e >>> 4 & 15) + t.charAt(15 & e);
|
|
397
447
|
return r;
|
|
398
448
|
}
|
|
399
|
-
function
|
|
400
|
-
for (var
|
|
401
|
-
|
|
402
|
-
for (t = 0; t < 8 *
|
|
403
|
-
|
|
404
|
-
return
|
|
449
|
+
function K(n) {
|
|
450
|
+
for (var e = Array(n.length >> 2), t = 0; t < e.length; t++)
|
|
451
|
+
e[t] = 0;
|
|
452
|
+
for (t = 0; t < 8 * n.length; t += 8)
|
|
453
|
+
e[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
|
|
454
|
+
return e;
|
|
405
455
|
}
|
|
406
|
-
function
|
|
407
|
-
for (var
|
|
408
|
-
|
|
409
|
-
return
|
|
456
|
+
function V(n) {
|
|
457
|
+
for (var e = "", t = 0; t < 32 * n.length; t += 8)
|
|
458
|
+
e += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
|
|
459
|
+
return e;
|
|
410
460
|
}
|
|
411
|
-
function
|
|
412
|
-
e
|
|
413
|
-
for (var t = 1732584193, r = -271733879, o = -1732584194, s = 271733878,
|
|
414
|
-
var
|
|
415
|
-
r =
|
|
461
|
+
function Z(n, e) {
|
|
462
|
+
n[e >> 5] |= 128 << e % 32, n[14 + (e + 64 >>> 9 << 4)] = e;
|
|
463
|
+
for (var t = 1732584193, r = -271733879, o = -1732584194, s = 271733878, i = 0; i < n.length; i += 16) {
|
|
464
|
+
var y = t, E = r, S = o, T = s;
|
|
465
|
+
r = h(r = h(r = h(r = h(r = a(r = a(r = a(r = a(r = u(r = u(r = u(r = u(r = c(r = c(r = c(r = c(r, o = c(o, s = c(s, t = c(t, r, o, s, n[i + 0], 7, -680876936), r, o, n[i + 1], 12, -389564586), t, r, n[i + 2], 17, 606105819), s, t, n[i + 3], 22, -1044525330), o = c(o, s = c(s, t = c(t, r, o, s, n[i + 4], 7, -176418897), r, o, n[i + 5], 12, 1200080426), t, r, n[i + 6], 17, -1473231341), s, t, n[i + 7], 22, -45705983), o = c(o, s = c(s, t = c(t, r, o, s, n[i + 8], 7, 1770035416), r, o, n[i + 9], 12, -1958414417), t, r, n[i + 10], 17, -42063), s, t, n[i + 11], 22, -1990404162), o = c(o, s = c(s, t = c(t, r, o, s, n[i + 12], 7, 1804603682), r, o, n[i + 13], 12, -40341101), t, r, n[i + 14], 17, -1502002290), s, t, n[i + 15], 22, 1236535329), o = u(o, s = u(s, t = u(t, r, o, s, n[i + 1], 5, -165796510), r, o, n[i + 6], 9, -1069501632), t, r, n[i + 11], 14, 643717713), s, t, n[i + 0], 20, -373897302), o = u(o, s = u(s, t = u(t, r, o, s, n[i + 5], 5, -701558691), r, o, n[i + 10], 9, 38016083), t, r, n[i + 15], 14, -660478335), s, t, n[i + 4], 20, -405537848), o = u(o, s = u(s, t = u(t, r, o, s, n[i + 9], 5, 568446438), r, o, n[i + 14], 9, -1019803690), t, r, n[i + 3], 14, -187363961), s, t, n[i + 8], 20, 1163531501), o = u(o, s = u(s, t = u(t, r, o, s, n[i + 13], 5, -1444681467), r, o, n[i + 2], 9, -51403784), t, r, n[i + 7], 14, 1735328473), s, t, n[i + 12], 20, -1926607734), o = a(o, s = a(s, t = a(t, r, o, s, n[i + 5], 4, -378558), r, o, n[i + 8], 11, -2022574463), t, r, n[i + 11], 16, 1839030562), s, t, n[i + 14], 23, -35309556), o = a(o, s = a(s, t = a(t, r, o, s, n[i + 1], 4, -1530992060), r, o, n[i + 4], 11, 1272893353), t, r, n[i + 7], 16, -155497632), s, t, n[i + 10], 23, -1094730640), o = a(o, s = a(s, t = a(t, r, o, s, n[i + 13], 4, 681279174), r, o, n[i + 0], 11, -358537222), t, r, n[i + 3], 16, -722521979), s, t, n[i + 6], 23, 76029189), o = a(o, s = a(s, t = a(t, r, o, s, n[i + 9], 4, -640364487), r, o, n[i + 12], 11, -421815835), t, r, n[i + 15], 16, 530742520), s, t, n[i + 2], 23, -995338651), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 0], 6, -198630844), r, o, n[i + 7], 10, 1126891415), t, r, n[i + 14], 15, -1416354905), s, t, n[i + 5], 21, -57434055), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 12], 6, 1700485571), r, o, n[i + 3], 10, -1894986606), t, r, n[i + 10], 15, -1051523), s, t, n[i + 1], 21, -2054922799), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 8], 6, 1873313359), r, o, n[i + 15], 10, -30611744), t, r, n[i + 6], 15, -1560198380), s, t, n[i + 13], 21, 1309151649), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 4], 6, -145523070), r, o, n[i + 11], 10, -1120210379), t, r, n[i + 2], 15, 718787259), s, t, n[i + 9], 21, -343485551), t = g(t, y), r = g(r, E), o = g(o, S), s = g(s, T);
|
|
416
466
|
}
|
|
417
467
|
return Array(t, r, o, s);
|
|
418
468
|
}
|
|
419
|
-
function
|
|
420
|
-
return
|
|
469
|
+
function O(n, e, t, r, o, s) {
|
|
470
|
+
return g(Q(g(g(e, n), g(r, s)), o), t);
|
|
421
471
|
}
|
|
422
|
-
function
|
|
423
|
-
return
|
|
472
|
+
function c(n, e, t, r, o, s, i) {
|
|
473
|
+
return O(e & t | ~e & r, n, e, o, s, i);
|
|
424
474
|
}
|
|
425
|
-
function u(
|
|
426
|
-
return
|
|
475
|
+
function u(n, e, t, r, o, s, i) {
|
|
476
|
+
return O(e & r | t & ~r, n, e, o, s, i);
|
|
427
477
|
}
|
|
428
|
-
function a(
|
|
429
|
-
return
|
|
478
|
+
function a(n, e, t, r, o, s, i) {
|
|
479
|
+
return O(e ^ t ^ r, n, e, o, s, i);
|
|
430
480
|
}
|
|
431
|
-
function
|
|
432
|
-
return
|
|
481
|
+
function h(n, e, t, r, o, s, i) {
|
|
482
|
+
return O(t ^ (e | ~r), n, e, o, s, i);
|
|
433
483
|
}
|
|
434
|
-
function
|
|
435
|
-
var t = (65535 &
|
|
436
|
-
return (
|
|
484
|
+
function g(n, e) {
|
|
485
|
+
var t = (65535 & n) + (65535 & e);
|
|
486
|
+
return (n >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
|
|
437
487
|
}
|
|
438
|
-
function
|
|
439
|
-
return
|
|
488
|
+
function Q(n, e) {
|
|
489
|
+
return n << e | n >>> 32 - e;
|
|
440
490
|
}
|
|
441
|
-
function
|
|
442
|
-
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
|
|
491
|
+
function Et(n) {
|
|
492
|
+
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
|
|
443
493
|
}
|
|
444
|
-
function
|
|
445
|
-
return Object.entries(
|
|
446
|
-
([
|
|
494
|
+
function xt(n) {
|
|
495
|
+
return Object.entries(n).map(
|
|
496
|
+
([e, t]) => encodeURIComponent(e) + "=" + encodeURIComponent(t)
|
|
447
497
|
).join("&");
|
|
448
498
|
}
|
|
449
|
-
function
|
|
450
|
-
return
|
|
499
|
+
function wt(n, e = "mp") {
|
|
500
|
+
return n ? `https://www.gravatar.com/avatar/${J(n)}?d=${e}` : "";
|
|
451
501
|
}
|
|
452
|
-
function
|
|
453
|
-
const
|
|
502
|
+
function Bt(n) {
|
|
503
|
+
const e = new RegExp(
|
|
454
504
|
"(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
|
|
455
505
|
"gm"
|
|
456
|
-
).exec(
|
|
506
|
+
).exec(n), t = (e == null ? void 0 : e.groups) ?? {}, r = t.domain.split(".");
|
|
457
507
|
if (t.port != null && (t.port = Number(t.port)), r.length > 2 && (t.domain = r.splice(-2, 2).join("."), t.subdomain = r.join(".")), t.query) {
|
|
458
508
|
const o = t.query.split("&"), s = {};
|
|
459
|
-
o.forEach((
|
|
460
|
-
const [
|
|
461
|
-
s[
|
|
509
|
+
o.forEach((i) => {
|
|
510
|
+
const [y, E] = i.split("=");
|
|
511
|
+
s[y] = E;
|
|
462
512
|
}), t.query = s;
|
|
463
513
|
}
|
|
464
514
|
return t;
|
|
465
515
|
}
|
|
466
|
-
function
|
|
467
|
-
return (
|
|
516
|
+
function At(n) {
|
|
517
|
+
return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
|
|
468
518
|
}
|
|
469
|
-
function
|
|
470
|
-
return new Promise((
|
|
519
|
+
function mt(n) {
|
|
520
|
+
return new Promise((e) => setTimeout(e, n));
|
|
471
521
|
}
|
|
472
|
-
function
|
|
473
|
-
const
|
|
522
|
+
function Ot(n) {
|
|
523
|
+
const e = n instanceof Date ? n : new Date(n);
|
|
474
524
|
return new Intl.DateTimeFormat("en-us", {
|
|
475
525
|
weekday: "long",
|
|
476
526
|
month: "short",
|
|
@@ -478,52 +528,54 @@ function Bt(e) {
|
|
|
478
528
|
hour: "numeric",
|
|
479
529
|
minute: "numeric",
|
|
480
530
|
hour12: !0
|
|
481
|
-
}).format(
|
|
531
|
+
}).format(e);
|
|
482
532
|
}
|
|
483
533
|
export {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
534
|
+
w as ASet,
|
|
535
|
+
D as BadRequestError,
|
|
536
|
+
ut as CliBackground,
|
|
537
|
+
x as CliEffects,
|
|
487
538
|
A as CliForeground,
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
539
|
+
p as CustomError,
|
|
540
|
+
k as ForbiddenError,
|
|
541
|
+
M as InternalServerError,
|
|
542
|
+
F as LOG_LEVEL,
|
|
543
|
+
b as Logger,
|
|
544
|
+
j as NotFoundError,
|
|
545
|
+
$ as TypedEmitter,
|
|
546
|
+
G as UnauthorizedError,
|
|
547
|
+
R as XHR,
|
|
548
|
+
nt as addUnique,
|
|
549
|
+
rt as arrayDiff,
|
|
550
|
+
ot as caseInsensitiveSort,
|
|
551
|
+
P as clean,
|
|
552
|
+
at as countChars,
|
|
553
|
+
ht as createHex,
|
|
554
|
+
_ as deepCopy,
|
|
555
|
+
m as dotNotation,
|
|
556
|
+
it as findByProp,
|
|
557
|
+
W as flattenArr,
|
|
558
|
+
H as flattenObj,
|
|
559
|
+
xt as formEncode,
|
|
560
|
+
Ot as formatDate,
|
|
561
|
+
lt as formatPhoneNumber,
|
|
562
|
+
wt as gravatar,
|
|
563
|
+
L as includes,
|
|
564
|
+
ft as insertAt,
|
|
565
|
+
B as isEqual,
|
|
566
|
+
ct as makeArray,
|
|
567
|
+
q as makeUnique,
|
|
568
|
+
pt as matchAll,
|
|
569
|
+
J as md5,
|
|
570
|
+
tt as mixin,
|
|
571
|
+
dt as pad,
|
|
572
|
+
yt as randomString,
|
|
573
|
+
gt as randomStringBuilder,
|
|
574
|
+
et as sanitizedJSON,
|
|
575
|
+
mt as sleep,
|
|
576
|
+
st as sortByProp,
|
|
577
|
+
At as timeUntil,
|
|
578
|
+
Bt as urlParser,
|
|
579
|
+
Et as validateEmail
|
|
528
580
|
};
|
|
529
581
|
//# sourceMappingURL=utils.mjs.map
|