@ztimson/utils 0.3.0 → 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/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.mjs +323 -283
- package/dist/utils.mjs.map +1 -1
- package/package.json +1 -1
package/dist/utils.mjs
CHANGED
|
@@ -1,200 +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
22
|
return t !== void 0 && s == i.length - 1 ? r[o] = t : r[o];
|
|
23
|
-
},
|
|
23
|
+
}, n);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (typeof
|
|
27
|
-
for (const r of Object.keys(
|
|
28
|
-
const o =
|
|
29
|
-
typeof
|
|
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 L(
|
|
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
|
|
57
|
+
function et(n, e) {
|
|
58
58
|
let t = [];
|
|
59
|
-
return JSON.parse(JSON.stringify(
|
|
59
|
+
return JSON.parse(JSON.stringify(n, (r, o) => {
|
|
60
60
|
if (typeof o == "object" && o !== null) {
|
|
61
61
|
if (t.includes(o))
|
|
62
62
|
return;
|
|
63
63
|
t.push(o);
|
|
64
64
|
}
|
|
65
65
|
return o;
|
|
66
|
-
},
|
|
66
|
+
}, e));
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
68
|
+
function nt(n, e) {
|
|
69
|
+
return n.indexOf(e) === -1 && n.push(e), n;
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return
|
|
73
|
-
...
|
|
74
|
-
...
|
|
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)))
|
|
75
75
|
]);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
return function(
|
|
79
|
-
const r =
|
|
77
|
+
function ot(n) {
|
|
78
|
+
return function(e, t) {
|
|
79
|
+
const r = m(e, n), o = m(t, n);
|
|
80
80
|
return typeof r != "string" || typeof o != "string" ? 1 : r.toLowerCase().localeCompare(o.toLowerCase());
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
return
|
|
83
|
+
function W(n, e = []) {
|
|
84
|
+
return n.forEach((t) => Array.isArray(t) ? W(t, e) : e.push(t)), e;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function st(n, e = !1) {
|
|
87
87
|
return function(t, r) {
|
|
88
|
-
const o =
|
|
89
|
-
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;
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
return (t) =>
|
|
92
|
+
function it(n, e) {
|
|
93
|
+
return (t) => B(t[n], e);
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
for (let
|
|
97
|
-
|
|
98
|
-
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
99
|
}
|
|
100
|
-
function
|
|
101
|
-
return Array.isArray(
|
|
100
|
+
function ct(n) {
|
|
101
|
+
return Array.isArray(n) ? n : [n];
|
|
102
102
|
}
|
|
103
|
-
class
|
|
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
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class $ {
|
|
104
143
|
constructor() {
|
|
105
|
-
|
|
144
|
+
l(this, "listeners", {});
|
|
106
145
|
}
|
|
107
|
-
static emit(
|
|
108
|
-
(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));
|
|
109
148
|
}
|
|
110
|
-
static off(
|
|
111
|
-
const r =
|
|
149
|
+
static off(e, t) {
|
|
150
|
+
const r = e.toString();
|
|
112
151
|
this.listeners[r] = (this.listeners[r] || []).filter((o) => o === t);
|
|
113
152
|
}
|
|
114
|
-
static on(
|
|
153
|
+
static on(e, t) {
|
|
115
154
|
var o;
|
|
116
|
-
const r =
|
|
117
|
-
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);
|
|
118
157
|
}
|
|
119
|
-
static once(
|
|
158
|
+
static once(e, t) {
|
|
120
159
|
return new Promise((r) => {
|
|
121
|
-
const o = this.on(
|
|
160
|
+
const o = this.on(e, (...s) => {
|
|
122
161
|
r(s.length == 1 ? s[0] : s), t && t(...s), o();
|
|
123
162
|
});
|
|
124
163
|
});
|
|
125
164
|
}
|
|
126
|
-
emit(
|
|
127
|
-
(this.listeners["*"] || []).forEach((r) => r(
|
|
165
|
+
emit(e, ...t) {
|
|
166
|
+
(this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e] || []).forEach((r) => r(...t));
|
|
128
167
|
}
|
|
129
|
-
off(
|
|
130
|
-
this.listeners[
|
|
168
|
+
off(e, t) {
|
|
169
|
+
this.listeners[e] = (this.listeners[e] || []).filter((r) => r === t);
|
|
131
170
|
}
|
|
132
|
-
on(
|
|
171
|
+
on(e, t) {
|
|
133
172
|
var r;
|
|
134
|
-
return this.listeners[
|
|
173
|
+
return this.listeners[e] || (this.listeners[e] = []), (r = this.listeners[e]) == null || r.push(t), () => this.off(e, t);
|
|
135
174
|
}
|
|
136
|
-
once(
|
|
175
|
+
once(e, t) {
|
|
137
176
|
return new Promise((r) => {
|
|
138
|
-
const o = this.on(
|
|
177
|
+
const o = this.on(e, (...s) => {
|
|
139
178
|
r(s.length == 1 ? s[0] : s), t && t(...s), o();
|
|
140
179
|
});
|
|
141
180
|
});
|
|
142
181
|
}
|
|
143
182
|
}
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
constructor(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
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));
|
|
150
189
|
}
|
|
151
|
-
static addInterceptor(
|
|
152
|
-
const t = Object.keys(
|
|
153
|
-
return
|
|
154
|
-
|
|
190
|
+
static addInterceptor(e) {
|
|
191
|
+
const t = Object.keys(d.interceptors).length.toString();
|
|
192
|
+
return d.interceptors[t] = e, () => {
|
|
193
|
+
d.interceptors[t] = null;
|
|
155
194
|
};
|
|
156
195
|
}
|
|
157
|
-
addInterceptor(
|
|
196
|
+
addInterceptor(e) {
|
|
158
197
|
const t = Object.keys(this.interceptors).length.toString();
|
|
159
|
-
return this.interceptors[t] =
|
|
198
|
+
return this.interceptors[t] = e, () => {
|
|
160
199
|
this.interceptors[t] = null;
|
|
161
200
|
};
|
|
162
201
|
}
|
|
163
|
-
async request(
|
|
202
|
+
async request(e = {}) {
|
|
164
203
|
var o, s;
|
|
165
|
-
if (!this.opts.url && !
|
|
204
|
+
if (!this.opts.url && !e.url)
|
|
166
205
|
throw new Error("URL needs to be set");
|
|
167
|
-
const t = ((o =
|
|
168
|
-
"Content-Type":
|
|
169
|
-
...
|
|
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,
|
|
170
209
|
...this.headers,
|
|
171
|
-
...
|
|
210
|
+
...e.headers
|
|
172
211
|
});
|
|
173
212
|
return fetch(t, {
|
|
174
213
|
headers: r,
|
|
175
|
-
method:
|
|
176
|
-
body: (s = r["Content-Type"]) != null && s.startsWith("application/json") &&
|
|
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
|
|
177
216
|
}).then(async (i) => {
|
|
178
|
-
var
|
|
179
|
-
for (let S of [...Object.values(
|
|
217
|
+
var y, E;
|
|
218
|
+
for (let S of [...Object.values(d.interceptors), ...Object.values(this.interceptors)])
|
|
180
219
|
await new Promise((T) => S(i, () => T()));
|
|
181
220
|
if (!i.ok)
|
|
182
221
|
throw new Error(i.statusText);
|
|
183
|
-
return (
|
|
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;
|
|
184
223
|
});
|
|
185
224
|
}
|
|
186
225
|
};
|
|
187
|
-
|
|
188
|
-
let R =
|
|
189
|
-
R.addInterceptor((
|
|
190
|
-
if (
|
|
191
|
-
return
|
|
192
|
-
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);
|
|
193
232
|
});
|
|
194
233
|
class p extends Error {
|
|
195
234
|
constructor(t, r) {
|
|
196
235
|
super(t);
|
|
197
|
-
|
|
236
|
+
l(this, "_code");
|
|
198
237
|
r != null && (this._code = r);
|
|
199
238
|
}
|
|
200
239
|
get code() {
|
|
@@ -218,53 +257,53 @@ class p extends Error {
|
|
|
218
257
|
return this.message || super.toString();
|
|
219
258
|
}
|
|
220
259
|
}
|
|
221
|
-
|
|
222
|
-
class $ extends p {
|
|
223
|
-
constructor(n = "Bad Request") {
|
|
224
|
-
super(n);
|
|
225
|
-
}
|
|
226
|
-
static instanceof(n) {
|
|
227
|
-
return n.constructor.code == this.code;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
h($, "code", 400);
|
|
260
|
+
l(p, "code", 500);
|
|
231
261
|
class D extends p {
|
|
232
|
-
constructor(
|
|
233
|
-
super(
|
|
262
|
+
constructor(e = "Bad Request") {
|
|
263
|
+
super(e);
|
|
234
264
|
}
|
|
235
|
-
static instanceof(
|
|
236
|
-
return
|
|
265
|
+
static instanceof(e) {
|
|
266
|
+
return e.constructor.code == this.code;
|
|
237
267
|
}
|
|
238
268
|
}
|
|
239
|
-
|
|
269
|
+
l(D, "code", 400);
|
|
240
270
|
class G extends p {
|
|
241
|
-
constructor(
|
|
242
|
-
super(
|
|
271
|
+
constructor(e = "Unauthorized") {
|
|
272
|
+
super(e);
|
|
243
273
|
}
|
|
244
|
-
static instanceof(
|
|
245
|
-
return
|
|
274
|
+
static instanceof(e) {
|
|
275
|
+
return e.constructor.code == this.code;
|
|
246
276
|
}
|
|
247
277
|
}
|
|
248
|
-
|
|
278
|
+
l(G, "code", 401);
|
|
249
279
|
class k extends p {
|
|
250
|
-
constructor(
|
|
251
|
-
super(
|
|
280
|
+
constructor(e = "Forbidden") {
|
|
281
|
+
super(e);
|
|
252
282
|
}
|
|
253
|
-
static instanceof(
|
|
254
|
-
return
|
|
283
|
+
static instanceof(e) {
|
|
284
|
+
return e.constructor.code == this.code;
|
|
255
285
|
}
|
|
256
286
|
}
|
|
257
|
-
|
|
287
|
+
l(k, "code", 403);
|
|
258
288
|
class j extends p {
|
|
259
|
-
constructor(
|
|
260
|
-
super(
|
|
289
|
+
constructor(e = "Not Found") {
|
|
290
|
+
super(e);
|
|
291
|
+
}
|
|
292
|
+
static instanceof(e) {
|
|
293
|
+
return e.constructor.code == this.code;
|
|
261
294
|
}
|
|
262
|
-
|
|
263
|
-
|
|
295
|
+
}
|
|
296
|
+
l(j, "code", 404);
|
|
297
|
+
class M extends p {
|
|
298
|
+
constructor(e = "Internal Server Error") {
|
|
299
|
+
super(e);
|
|
300
|
+
}
|
|
301
|
+
static instanceof(e) {
|
|
302
|
+
return e.constructor.code == this.code;
|
|
264
303
|
}
|
|
265
304
|
}
|
|
266
|
-
|
|
267
|
-
const
|
|
305
|
+
l(M, "code", 500);
|
|
306
|
+
const x = {
|
|
268
307
|
CLEAR: "\x1B[0m",
|
|
269
308
|
BRIGHT: "\x1B[1m",
|
|
270
309
|
DIM: "\x1B[2m",
|
|
@@ -289,7 +328,7 @@ const w = {
|
|
|
289
328
|
LIGHT_MAGENTA: "\x1B[95m",
|
|
290
329
|
LIGHT_CYAN: "\x1B[96m",
|
|
291
330
|
WHITE: "\x1B[97m"
|
|
292
|
-
},
|
|
331
|
+
}, ut = {
|
|
293
332
|
BLACK: "\x1B[40m",
|
|
294
333
|
RED: "\x1B[41m",
|
|
295
334
|
GREEN: "\x1B[42m",
|
|
@@ -300,188 +339,188 @@ const w = {
|
|
|
300
339
|
WHITE: "\x1B[47m",
|
|
301
340
|
GREY: "\x1B[100m"
|
|
302
341
|
};
|
|
303
|
-
var
|
|
304
|
-
const f = class f extends
|
|
305
|
-
constructor(
|
|
306
|
-
super(), this.namespace =
|
|
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;
|
|
307
346
|
}
|
|
308
|
-
pad(
|
|
309
|
-
const s =
|
|
347
|
+
pad(e, t, r, o = !1) {
|
|
348
|
+
const s = e.toString(), i = t - s.length;
|
|
310
349
|
if (i <= 0)
|
|
311
350
|
return s;
|
|
312
|
-
const
|
|
313
|
-
return o ? s +
|
|
351
|
+
const y = Array(~~(i / r.length)).fill(r).join("");
|
|
352
|
+
return o ? s + y : y + s;
|
|
314
353
|
}
|
|
315
|
-
format(...
|
|
354
|
+
format(...e) {
|
|
316
355
|
const t = /* @__PURE__ */ new Date();
|
|
317
|
-
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(" ")}`;
|
|
318
357
|
}
|
|
319
|
-
debug(...
|
|
358
|
+
debug(...e) {
|
|
320
359
|
if (f.LOG_LEVEL < 4)
|
|
321
360
|
return;
|
|
322
|
-
const t = this.format(...
|
|
323
|
-
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);
|
|
324
363
|
}
|
|
325
|
-
log(...
|
|
364
|
+
log(...e) {
|
|
326
365
|
if (f.LOG_LEVEL < 3)
|
|
327
366
|
return;
|
|
328
|
-
const t = this.format(...
|
|
329
|
-
f.emit(3, t), console.log(
|
|
367
|
+
const t = this.format(...e);
|
|
368
|
+
f.emit(3, t), console.log(x.CLEAR + t);
|
|
330
369
|
}
|
|
331
|
-
info(...
|
|
370
|
+
info(...e) {
|
|
332
371
|
if (f.LOG_LEVEL < 2)
|
|
333
372
|
return;
|
|
334
|
-
const t = this.format(...
|
|
335
|
-
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);
|
|
336
375
|
}
|
|
337
|
-
warn(...
|
|
376
|
+
warn(...e) {
|
|
338
377
|
if (f.LOG_LEVEL < 1)
|
|
339
378
|
return;
|
|
340
|
-
const t = this.format(...
|
|
341
|
-
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);
|
|
342
381
|
}
|
|
343
|
-
error(...
|
|
382
|
+
error(...e) {
|
|
344
383
|
if (f.LOG_LEVEL < 0)
|
|
345
384
|
return;
|
|
346
|
-
const t = this.format(...
|
|
347
|
-
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);
|
|
348
387
|
}
|
|
349
388
|
};
|
|
350
|
-
|
|
351
|
-
let
|
|
352
|
-
function
|
|
353
|
-
return
|
|
354
|
-
}
|
|
355
|
-
function
|
|
356
|
-
return Array(
|
|
357
|
-
}
|
|
358
|
-
const
|
|
359
|
-
function lt(
|
|
360
|
-
const
|
|
361
|
-
if (!
|
|
362
|
-
throw new Error(`Number cannot be parsed: ${
|
|
363
|
-
return `${
|
|
364
|
-
}
|
|
365
|
-
function
|
|
366
|
-
return `${
|
|
367
|
-
}
|
|
368
|
-
function
|
|
369
|
-
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;
|
|
370
409
|
if (s <= 0)
|
|
371
410
|
return o;
|
|
372
411
|
const i = Array(~~(s / t.length)).fill(t).join("");
|
|
373
412
|
return r ? i + o : o + i;
|
|
374
413
|
}
|
|
375
|
-
function yt(
|
|
376
|
-
return Array(
|
|
377
|
-
const t = ~~(Math.random() *
|
|
378
|
-
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];
|
|
379
418
|
}).join("");
|
|
380
419
|
}
|
|
381
|
-
function gt(
|
|
382
|
-
if (!
|
|
420
|
+
function gt(n, e = !1, t = !1, r = !1) {
|
|
421
|
+
if (!e && !t && !r)
|
|
383
422
|
throw new Error("Must enable at least one: letters, numbers, symbols");
|
|
384
|
-
return Array(
|
|
423
|
+
return Array(n).fill(null).map(() => {
|
|
385
424
|
let o;
|
|
386
425
|
do {
|
|
387
426
|
const s = ~~(Math.random() * 3);
|
|
388
|
-
|
|
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)]);
|
|
389
428
|
} while (!o);
|
|
390
429
|
return o;
|
|
391
430
|
}).join("");
|
|
392
431
|
}
|
|
393
|
-
function
|
|
394
|
-
if (typeof
|
|
432
|
+
function pt(n, e) {
|
|
433
|
+
if (typeof e == "string" && (e = new RegExp(e, "g")), !e.global)
|
|
395
434
|
throw new TypeError("Regular expression must be global.");
|
|
396
435
|
let t = [], r;
|
|
397
|
-
for (; (r =
|
|
436
|
+
for (; (r = e.exec(n)) !== null; )
|
|
398
437
|
t.push(r);
|
|
399
438
|
return t;
|
|
400
439
|
}
|
|
401
|
-
function J(
|
|
402
|
-
var
|
|
403
|
-
return
|
|
440
|
+
function J(n) {
|
|
441
|
+
var e = v(V(Z(K(n), 8 * n.length)));
|
|
442
|
+
return e.toLowerCase();
|
|
404
443
|
}
|
|
405
|
-
function v(
|
|
406
|
-
for (var
|
|
407
|
-
|
|
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);
|
|
408
447
|
return r;
|
|
409
448
|
}
|
|
410
|
-
function
|
|
411
|
-
for (var
|
|
412
|
-
|
|
413
|
-
for (t = 0; t < 8 *
|
|
414
|
-
|
|
415
|
-
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;
|
|
416
455
|
}
|
|
417
|
-
function
|
|
418
|
-
for (var
|
|
419
|
-
|
|
420
|
-
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;
|
|
421
460
|
}
|
|
422
|
-
function
|
|
423
|
-
e
|
|
424
|
-
for (var t = 1732584193, r = -271733879, o = -1732584194, s = 271733878, i = 0; i <
|
|
425
|
-
var
|
|
426
|
-
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);
|
|
427
466
|
}
|
|
428
467
|
return Array(t, r, o, s);
|
|
429
468
|
}
|
|
430
|
-
function
|
|
431
|
-
return
|
|
469
|
+
function O(n, e, t, r, o, s) {
|
|
470
|
+
return g(Q(g(g(e, n), g(r, s)), o), t);
|
|
432
471
|
}
|
|
433
|
-
function c(
|
|
434
|
-
return
|
|
472
|
+
function c(n, e, t, r, o, s, i) {
|
|
473
|
+
return O(e & t | ~e & r, n, e, o, s, i);
|
|
435
474
|
}
|
|
436
|
-
function u(
|
|
437
|
-
return
|
|
475
|
+
function u(n, e, t, r, o, s, i) {
|
|
476
|
+
return O(e & r | t & ~r, n, e, o, s, i);
|
|
438
477
|
}
|
|
439
|
-
function a(
|
|
440
|
-
return
|
|
478
|
+
function a(n, e, t, r, o, s, i) {
|
|
479
|
+
return O(e ^ t ^ r, n, e, o, s, i);
|
|
441
480
|
}
|
|
442
|
-
function
|
|
443
|
-
return
|
|
481
|
+
function h(n, e, t, r, o, s, i) {
|
|
482
|
+
return O(t ^ (e | ~r), n, e, o, s, i);
|
|
444
483
|
}
|
|
445
|
-
function
|
|
446
|
-
var t = (65535 &
|
|
447
|
-
return (
|
|
484
|
+
function g(n, e) {
|
|
485
|
+
var t = (65535 & n) + (65535 & e);
|
|
486
|
+
return (n >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
|
|
448
487
|
}
|
|
449
|
-
function
|
|
450
|
-
return
|
|
488
|
+
function Q(n, e) {
|
|
489
|
+
return n << e | n >>> 32 - e;
|
|
451
490
|
}
|
|
452
|
-
function
|
|
453
|
-
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);
|
|
454
493
|
}
|
|
455
|
-
function
|
|
456
|
-
return Object.entries(
|
|
457
|
-
([
|
|
494
|
+
function xt(n) {
|
|
495
|
+
return Object.entries(n).map(
|
|
496
|
+
([e, t]) => encodeURIComponent(e) + "=" + encodeURIComponent(t)
|
|
458
497
|
).join("&");
|
|
459
498
|
}
|
|
460
|
-
function wt(
|
|
461
|
-
return
|
|
499
|
+
function wt(n, e = "mp") {
|
|
500
|
+
return n ? `https://www.gravatar.com/avatar/${J(n)}?d=${e}` : "";
|
|
462
501
|
}
|
|
463
|
-
function
|
|
464
|
-
const
|
|
502
|
+
function Bt(n) {
|
|
503
|
+
const e = new RegExp(
|
|
465
504
|
"(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
|
|
466
505
|
"gm"
|
|
467
|
-
).exec(
|
|
506
|
+
).exec(n), t = (e == null ? void 0 : e.groups) ?? {}, r = t.domain.split(".");
|
|
468
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) {
|
|
469
508
|
const o = t.query.split("&"), s = {};
|
|
470
509
|
o.forEach((i) => {
|
|
471
|
-
const [
|
|
472
|
-
s[
|
|
510
|
+
const [y, E] = i.split("=");
|
|
511
|
+
s[y] = E;
|
|
473
512
|
}), t.query = s;
|
|
474
513
|
}
|
|
475
514
|
return t;
|
|
476
515
|
}
|
|
477
|
-
function At(
|
|
478
|
-
return (
|
|
516
|
+
function At(n) {
|
|
517
|
+
return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
|
|
479
518
|
}
|
|
480
|
-
function
|
|
481
|
-
return new Promise((
|
|
519
|
+
function mt(n) {
|
|
520
|
+
return new Promise((e) => setTimeout(e, n));
|
|
482
521
|
}
|
|
483
|
-
function
|
|
484
|
-
const
|
|
522
|
+
function Ot(n) {
|
|
523
|
+
const e = n instanceof Date ? n : new Date(n);
|
|
485
524
|
return new Intl.DateTimeFormat("en-us", {
|
|
486
525
|
weekday: "long",
|
|
487
526
|
month: "short",
|
|
@@ -489,53 +528,54 @@ function mt(e) {
|
|
|
489
528
|
hour: "numeric",
|
|
490
529
|
minute: "numeric",
|
|
491
530
|
hour12: !0
|
|
492
|
-
}).format(
|
|
531
|
+
}).format(e);
|
|
493
532
|
}
|
|
494
533
|
export {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
534
|
+
w as ASet,
|
|
535
|
+
D as BadRequestError,
|
|
536
|
+
ut as CliBackground,
|
|
537
|
+
x as CliEffects,
|
|
498
538
|
A as CliForeground,
|
|
499
539
|
p as CustomError,
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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,
|
|
507
547
|
R as XHR,
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
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,
|
|
521
561
|
lt as formatPhoneNumber,
|
|
522
562
|
wt as gravatar,
|
|
523
563
|
L as includes,
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
564
|
+
ft as insertAt,
|
|
565
|
+
B as isEqual,
|
|
566
|
+
ct as makeArray,
|
|
567
|
+
q as makeUnique,
|
|
568
|
+
pt as matchAll,
|
|
529
569
|
J as md5,
|
|
530
|
-
|
|
531
|
-
|
|
570
|
+
tt as mixin,
|
|
571
|
+
dt as pad,
|
|
532
572
|
yt as randomString,
|
|
533
573
|
gt as randomStringBuilder,
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
574
|
+
et as sanitizedJSON,
|
|
575
|
+
mt as sleep,
|
|
576
|
+
st as sortByProp,
|
|
537
577
|
At as timeUntil,
|
|
538
|
-
|
|
539
|
-
|
|
578
|
+
Bt as urlParser,
|
|
579
|
+
Et as validateEmail
|
|
540
580
|
};
|
|
541
581
|
//# sourceMappingURL=utils.mjs.map
|