@ztimson/utils 0.21.2 → 0.21.3
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 +8 -0
- package/dist/index.cjs +1397 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +934 -716
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,123 +1,162 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
function at(r, ...t) {
|
|
14
|
-
return t.forEach((e) => {
|
|
15
|
-
for (const n in e)
|
|
16
|
-
e[n] && typeof e[n] == "object" && !Array.isArray(e[n]) ? (r[n] || (r[n] = {}), at(r[n], e[n])) : r[n] = e[n];
|
|
17
|
-
}), r;
|
|
18
|
-
}
|
|
19
|
-
function B(r, t, e) {
|
|
20
|
-
if (!(r == null || !t))
|
|
21
|
-
return t.split(/[.[\]]/g).filter((n) => n.length).reduce((n, s, o, i) => {
|
|
22
|
-
if ((s[0] == '"' || s[0] == "'") && (s = s.slice(1, -1)), !(n != null && n.hasOwnProperty(s))) {
|
|
23
|
-
if (e == null) return;
|
|
24
|
-
n[s] = {};
|
|
25
|
-
}
|
|
26
|
-
return e !== void 0 && o == i.length - 1 ? n[s] = e : n[s];
|
|
27
|
-
}, r);
|
|
28
|
-
}
|
|
29
|
-
function Rt(r) {
|
|
30
|
-
return Object.entries(r).map(
|
|
31
|
-
([t, e]) => encodeURIComponent(t) + "=" + encodeURIComponent(e)
|
|
32
|
-
).join("&");
|
|
33
|
-
}
|
|
34
|
-
function K(r, t, e = {}) {
|
|
35
|
-
if (typeof r == "object" && !Array.isArray(r)) {
|
|
36
|
-
for (const n of Object.keys(r)) {
|
|
37
|
-
const s = t ? t + "." + n : n;
|
|
38
|
-
typeof r[n] == "object" ? K(r[n], s, e) : e[s] = r[n];
|
|
39
|
-
}
|
|
40
|
-
return e;
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
function clean(obj, undefinedOnly = false) {
|
|
5
|
+
if (obj == null) throw new Error("Cannot clean a NULL value");
|
|
6
|
+
if (Array.isArray(obj)) {
|
|
7
|
+
obj = obj.filter((o) => o != null);
|
|
8
|
+
} else {
|
|
9
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
10
|
+
if (undefinedOnly && value === void 0 || !undefinedOnly && value == null) delete obj[key];
|
|
11
|
+
});
|
|
41
12
|
}
|
|
13
|
+
return obj;
|
|
42
14
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
return Object.entries(r).forEach(([e, n]) => t.append(e, n)), t;
|
|
15
|
+
function deepCopy(value) {
|
|
16
|
+
return structuredClone(value);
|
|
46
17
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
18
|
+
function deepMerge(target, ...sources) {
|
|
19
|
+
sources.forEach((s) => {
|
|
20
|
+
for (const key in s) {
|
|
21
|
+
if (s[key] && typeof s[key] == "object" && !Array.isArray(s[key])) {
|
|
22
|
+
if (!target[key]) target[key] = {};
|
|
23
|
+
deepMerge(target[key], s[key]);
|
|
24
|
+
} else {
|
|
25
|
+
target[key] = s[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return target;
|
|
30
|
+
}
|
|
31
|
+
function dotNotation(obj, prop, set) {
|
|
32
|
+
if (obj == null || !prop) return void 0;
|
|
33
|
+
return prop.split(/[.[\]]/g).filter((prop2) => prop2.length).reduce((obj2, prop2, i, arr) => {
|
|
34
|
+
if (prop2[0] == '"' || prop2[0] == "'") prop2 = prop2.slice(1, -1);
|
|
35
|
+
if (!(obj2 == null ? void 0 : obj2.hasOwnProperty(prop2))) {
|
|
36
|
+
if (set == void 0) return void 0;
|
|
37
|
+
obj2[prop2] = {};
|
|
38
|
+
}
|
|
39
|
+
if (set !== void 0 && i == arr.length - 1)
|
|
40
|
+
return obj2[prop2] = set;
|
|
41
|
+
return obj2[prop2];
|
|
42
|
+
}, obj);
|
|
43
|
+
}
|
|
44
|
+
function encodeQuery(data) {
|
|
45
|
+
return Object.entries(data).map(
|
|
46
|
+
([key, value]) => encodeURIComponent(key) + "=" + encodeURIComponent(value)
|
|
47
|
+
).join("&");
|
|
56
48
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
Object.
|
|
49
|
+
function flattenObj(obj, parent, result = {}) {
|
|
50
|
+
if (typeof obj === "object" && !Array.isArray(obj)) {
|
|
51
|
+
for (const key of Object.keys(obj)) {
|
|
52
|
+
const propName = parent ? parent + "." + key : key;
|
|
53
|
+
if (typeof obj[key] === "object") {
|
|
54
|
+
flattenObj(obj[key], propName, result);
|
|
55
|
+
} else {
|
|
56
|
+
result[propName] = obj[key];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return result;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function formData(target) {
|
|
63
|
+
const data = new FormData();
|
|
64
|
+
Object.entries(target).forEach(([key, value]) => data.append(key, value));
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
function includes(target, values, allowMissing = false) {
|
|
68
|
+
if (target == void 0) return allowMissing;
|
|
69
|
+
if (Array.isArray(values)) return values.findIndex((e, i) => !includes(target[i], values[i], allowMissing)) == -1;
|
|
70
|
+
const type = typeof values;
|
|
71
|
+
if (type != typeof target) return false;
|
|
72
|
+
if (type == "object") {
|
|
73
|
+
return Object.keys(values).find((key) => !includes(target[key], values[key], allowMissing)) == null;
|
|
74
|
+
}
|
|
75
|
+
if (type == "function") return target.toString() == values.toString();
|
|
76
|
+
return target == values;
|
|
77
|
+
}
|
|
78
|
+
function isEqual(a, b) {
|
|
79
|
+
const ta = typeof a, tb = typeof b;
|
|
80
|
+
if (ta != "object" || a == null || (tb != "object" || b == null))
|
|
81
|
+
return ta == "function" && tb == "function" ? a.toString() == b.toString() : a === b;
|
|
82
|
+
const keys = Object.keys(a);
|
|
83
|
+
if (keys.length != Object.keys(b).length) return false;
|
|
84
|
+
return Object.keys(a).every((key) => isEqual(a[key], b[key]));
|
|
85
|
+
}
|
|
86
|
+
function mixin(target, constructors) {
|
|
87
|
+
constructors.forEach((c) => {
|
|
88
|
+
Object.getOwnPropertyNames(c.prototype).forEach((name) => {
|
|
60
89
|
Object.defineProperty(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Object.getOwnPropertyDescriptor(
|
|
90
|
+
target.prototype,
|
|
91
|
+
name,
|
|
92
|
+
Object.getOwnPropertyDescriptor(c.prototype, name) || /* @__PURE__ */ Object.create(null)
|
|
64
93
|
);
|
|
65
94
|
});
|
|
66
95
|
});
|
|
67
96
|
}
|
|
68
|
-
function
|
|
97
|
+
function JSONAttemptParse(json) {
|
|
69
98
|
try {
|
|
70
|
-
return JSON.parse(
|
|
99
|
+
return JSON.parse(json);
|
|
71
100
|
} catch {
|
|
72
|
-
return
|
|
101
|
+
return json;
|
|
73
102
|
}
|
|
74
103
|
}
|
|
75
|
-
function
|
|
76
|
-
let
|
|
77
|
-
return JSON.stringify(
|
|
78
|
-
if (typeof
|
|
79
|
-
if (
|
|
80
|
-
|
|
104
|
+
function JSONSanitize(obj, space) {
|
|
105
|
+
let cache = [];
|
|
106
|
+
return JSON.stringify(obj, (key, value) => {
|
|
107
|
+
if (typeof value === "object" && value !== null) {
|
|
108
|
+
if (cache.includes(value)) return;
|
|
109
|
+
cache.push(value);
|
|
81
110
|
}
|
|
82
|
-
return
|
|
83
|
-
},
|
|
111
|
+
return value;
|
|
112
|
+
}, space);
|
|
84
113
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
114
|
+
function addUnique(array, el) {
|
|
115
|
+
if (array.indexOf(el) === -1) array.push(el);
|
|
116
|
+
return array;
|
|
87
117
|
}
|
|
88
|
-
function
|
|
89
|
-
return
|
|
90
|
-
...
|
|
91
|
-
...
|
|
118
|
+
function arrayDiff(a, b) {
|
|
119
|
+
return makeUnique([
|
|
120
|
+
...a.filter((v1) => !b.includes((v2) => isEqual(v1, v2))),
|
|
121
|
+
...b.filter((v1) => !a.includes((v2) => isEqual(v1, v2)))
|
|
92
122
|
]);
|
|
93
123
|
}
|
|
94
|
-
function
|
|
95
|
-
return function(
|
|
96
|
-
const
|
|
97
|
-
|
|
124
|
+
function caseInsensitiveSort(prop) {
|
|
125
|
+
return function(a, b) {
|
|
126
|
+
const aVal = dotNotation(a, prop);
|
|
127
|
+
const bVal = dotNotation(b, prop);
|
|
128
|
+
if (typeof aVal !== "string" || typeof bVal !== "string") return 1;
|
|
129
|
+
return aVal.toLowerCase().localeCompare(bVal.toLowerCase());
|
|
98
130
|
};
|
|
99
131
|
}
|
|
100
|
-
function
|
|
101
|
-
return (
|
|
102
|
-
}
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
132
|
+
function findByProp(prop, value) {
|
|
133
|
+
return (v) => isEqual(dotNotation(v, prop), value);
|
|
134
|
+
}
|
|
135
|
+
function flattenArr(arr, result = []) {
|
|
136
|
+
arr.forEach((el) => Array.isArray(el) ? flattenArr(el, result) : result.push(el));
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
function sortByProp(prop, reverse = false) {
|
|
140
|
+
return function(a, b) {
|
|
141
|
+
const aVal = dotNotation(a, prop);
|
|
142
|
+
const bVal = dotNotation(b, prop);
|
|
143
|
+
if (typeof aVal == "number" && typeof bVal == "number")
|
|
144
|
+
return (reverse ? -1 : 1) * (aVal - bVal);
|
|
145
|
+
if (aVal > bVal) return reverse ? -1 : 1;
|
|
146
|
+
if (aVal < bVal) return reverse ? 1 : -1;
|
|
147
|
+
return 0;
|
|
110
148
|
};
|
|
111
149
|
}
|
|
112
|
-
function
|
|
113
|
-
for (let
|
|
114
|
-
|
|
115
|
-
|
|
150
|
+
function makeUnique(arr) {
|
|
151
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
152
|
+
if (arr.slice(0, i).find((n) => isEqual(n, arr[i]))) arr.splice(i, 1);
|
|
153
|
+
}
|
|
154
|
+
return arr;
|
|
116
155
|
}
|
|
117
|
-
function
|
|
118
|
-
return Array.isArray(
|
|
156
|
+
function makeArray(value) {
|
|
157
|
+
return Array.isArray(value) ? value : [value];
|
|
119
158
|
}
|
|
120
|
-
class
|
|
159
|
+
class ASet extends Array {
|
|
121
160
|
/** Number of elements in set */
|
|
122
161
|
get size() {
|
|
123
162
|
return this.length;
|
|
@@ -126,124 +165,150 @@ class w extends Array {
|
|
|
126
165
|
* Array to create set from, duplicate values will be removed
|
|
127
166
|
* @param {T[]} elements Elements which will be added to set
|
|
128
167
|
*/
|
|
129
|
-
constructor(
|
|
130
|
-
super()
|
|
168
|
+
constructor(elements = []) {
|
|
169
|
+
super();
|
|
170
|
+
if (!!(elements == null ? void 0 : elements["forEach"]))
|
|
171
|
+
elements.forEach((el) => this.add(el));
|
|
131
172
|
}
|
|
132
173
|
/**
|
|
133
174
|
* Add elements to set if unique
|
|
134
175
|
* @param items
|
|
135
176
|
*/
|
|
136
|
-
add(...
|
|
137
|
-
|
|
177
|
+
add(...items) {
|
|
178
|
+
items.filter((el) => !this.has(el)).forEach((el) => this.push(el));
|
|
179
|
+
return this;
|
|
138
180
|
}
|
|
139
181
|
/**
|
|
140
182
|
* Delete elements from set
|
|
141
183
|
* @param items Elements that will be deleted
|
|
142
184
|
*/
|
|
143
|
-
delete(...
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
})
|
|
185
|
+
delete(...items) {
|
|
186
|
+
items.forEach((el) => {
|
|
187
|
+
const index = this.indexOf(el);
|
|
188
|
+
if (index != -1) this.splice(index, 1);
|
|
189
|
+
});
|
|
190
|
+
return this;
|
|
148
191
|
}
|
|
149
192
|
/**
|
|
150
193
|
* Create list of elements this set has which the comparison set does not
|
|
151
194
|
* @param {ASet<T>} set Set to compare against
|
|
152
195
|
* @return {ASet<T>} Different elements
|
|
153
196
|
*/
|
|
154
|
-
difference(
|
|
155
|
-
return new
|
|
197
|
+
difference(set) {
|
|
198
|
+
return new ASet(this.filter((el) => !set.has(el)));
|
|
156
199
|
}
|
|
157
200
|
/**
|
|
158
201
|
* Check if set includes element
|
|
159
202
|
* @param {T} el Element to look for
|
|
160
203
|
* @return {boolean} True if element was found, false otherwise
|
|
161
204
|
*/
|
|
162
|
-
has(
|
|
163
|
-
return this.indexOf(
|
|
205
|
+
has(el) {
|
|
206
|
+
return this.indexOf(el) != -1;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Find index number of element, or -1 if it doesn't exist. Matches by equality not reference
|
|
210
|
+
*
|
|
211
|
+
* @param {T} search Element to find
|
|
212
|
+
* @param {number} fromIndex Starting index position
|
|
213
|
+
* @return {number} Element index number or -1 if missing
|
|
214
|
+
*/
|
|
215
|
+
indexOf(search, fromIndex) {
|
|
216
|
+
return super.findIndex((el) => isEqual(el, search), fromIndex);
|
|
164
217
|
}
|
|
165
218
|
/**
|
|
166
219
|
* Create list of elements this set has in common with the comparison set
|
|
167
220
|
* @param {ASet<T>} set Set to compare against
|
|
168
221
|
* @return {boolean} Set of common elements
|
|
169
222
|
*/
|
|
170
|
-
intersection(
|
|
171
|
-
return new
|
|
223
|
+
intersection(set) {
|
|
224
|
+
return new ASet(this.filter((el) => set.has(el)));
|
|
172
225
|
}
|
|
173
226
|
/**
|
|
174
227
|
* Check if this set has no elements in common with the comparison set
|
|
175
228
|
* @param {ASet<T>} set Set to compare against
|
|
176
229
|
* @return {boolean} True if nothing in common, false otherwise
|
|
177
230
|
*/
|
|
178
|
-
isDisjointFrom(
|
|
179
|
-
return this.intersection(
|
|
231
|
+
isDisjointFrom(set) {
|
|
232
|
+
return this.intersection(set).size == 0;
|
|
180
233
|
}
|
|
181
234
|
/**
|
|
182
235
|
* Check if all elements in this set are included in the comparison set
|
|
183
236
|
* @param {ASet<T>} set Set to compare against
|
|
184
237
|
* @return {boolean} True if all elements are included, false otherwise
|
|
185
238
|
*/
|
|
186
|
-
isSubsetOf(
|
|
187
|
-
return this.findIndex((
|
|
239
|
+
isSubsetOf(set) {
|
|
240
|
+
return this.findIndex((el) => !set.has(el)) == -1;
|
|
188
241
|
}
|
|
189
242
|
/**
|
|
190
243
|
* Check if all elements from comparison set are included in this set
|
|
191
244
|
* @param {ASet<T>} set Set to compare against
|
|
192
245
|
* @return {boolean} True if all elements are included, false otherwise
|
|
193
246
|
*/
|
|
194
|
-
isSuperset(
|
|
195
|
-
return
|
|
247
|
+
isSuperset(set) {
|
|
248
|
+
return set.findIndex((el) => !this.has(el)) == -1;
|
|
196
249
|
}
|
|
197
250
|
/**
|
|
198
251
|
* Create list of elements that are only in one set but not both (XOR)
|
|
199
252
|
* @param {ASet<T>} set Set to compare against
|
|
200
253
|
* @return {ASet<T>} New set of unique elements
|
|
201
254
|
*/
|
|
202
|
-
symmetricDifference(
|
|
203
|
-
return new
|
|
255
|
+
symmetricDifference(set) {
|
|
256
|
+
return new ASet([...this.difference(set), ...set.difference(this)]);
|
|
204
257
|
}
|
|
205
258
|
/**
|
|
206
259
|
* Create joined list of elements included in this & the comparison set
|
|
207
260
|
* @param {ASet<T>} set Set join
|
|
208
261
|
* @return {ASet<T>} New set of both previous sets combined
|
|
209
262
|
*/
|
|
210
|
-
union(
|
|
211
|
-
return new
|
|
263
|
+
union(set) {
|
|
264
|
+
return new ASet([...this, ...set]);
|
|
212
265
|
}
|
|
213
266
|
}
|
|
214
|
-
class
|
|
267
|
+
class Cache {
|
|
215
268
|
/**
|
|
216
269
|
* Create new cache
|
|
217
270
|
*
|
|
218
271
|
* @param {keyof T} key Default property to use as primary key
|
|
219
272
|
* @param options
|
|
220
273
|
*/
|
|
221
|
-
constructor(
|
|
222
|
-
|
|
274
|
+
constructor(key, options = {}) {
|
|
275
|
+
__publicField(this, "store", {});
|
|
223
276
|
/** Whether cache is complete */
|
|
224
|
-
|
|
277
|
+
__publicField(this, "complete", false);
|
|
225
278
|
/**
|
|
226
279
|
* Get all cached items
|
|
227
280
|
*
|
|
228
281
|
* @return {T[]} Array of items
|
|
229
282
|
*/
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
283
|
+
__publicField(this, "values", this.all());
|
|
284
|
+
this.key = key;
|
|
285
|
+
this.options = options;
|
|
286
|
+
if (options.storageKey && !options.storage && typeof Storage !== "undefined")
|
|
287
|
+
options.storage = localStorage;
|
|
288
|
+
if (options.storageKey && options.storage) {
|
|
289
|
+
const stored = options.storage.getItem(options.storageKey);
|
|
290
|
+
if (stored) {
|
|
234
291
|
try {
|
|
235
|
-
Object.assign(this.store, JSON.parse(
|
|
292
|
+
Object.assign(this.store, JSON.parse(stored));
|
|
236
293
|
} catch {
|
|
237
294
|
}
|
|
295
|
+
}
|
|
238
296
|
}
|
|
239
297
|
return new Proxy(this, {
|
|
240
|
-
get: (
|
|
241
|
-
|
|
298
|
+
get: (target, prop) => {
|
|
299
|
+
if (prop in target) return target[prop];
|
|
300
|
+
return target.store[prop];
|
|
301
|
+
},
|
|
302
|
+
set: (target, prop, value) => {
|
|
303
|
+
if (prop in target) target[prop] = value;
|
|
304
|
+
else target.store[prop] = value;
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
242
307
|
});
|
|
243
308
|
}
|
|
244
|
-
getKey(
|
|
309
|
+
getKey(value) {
|
|
245
310
|
if (!this.key) throw new Error("No key defined");
|
|
246
|
-
return
|
|
311
|
+
return value[this.key];
|
|
247
312
|
}
|
|
248
313
|
/**
|
|
249
314
|
* Get all cached items
|
|
@@ -260,9 +325,10 @@ class It {
|
|
|
260
325
|
* @param {number | undefined} ttl Override default expiry
|
|
261
326
|
* @return {this}
|
|
262
327
|
*/
|
|
263
|
-
add(
|
|
264
|
-
const
|
|
265
|
-
|
|
328
|
+
add(value, ttl = this.ttl) {
|
|
329
|
+
const key = this.getKey(value);
|
|
330
|
+
this.set(key, value, ttl);
|
|
331
|
+
return this;
|
|
266
332
|
}
|
|
267
333
|
/**
|
|
268
334
|
* Add several rows to the cache
|
|
@@ -271,8 +337,10 @@ class It {
|
|
|
271
337
|
* @param complete Mark cache as complete & reliable, defaults to true
|
|
272
338
|
* @return {this}
|
|
273
339
|
*/
|
|
274
|
-
addAll(
|
|
275
|
-
|
|
340
|
+
addAll(rows, complete = true) {
|
|
341
|
+
rows.forEach((r) => this.add(r));
|
|
342
|
+
this.complete = complete;
|
|
343
|
+
return this;
|
|
276
344
|
}
|
|
277
345
|
/**
|
|
278
346
|
* Remove all keys from cache
|
|
@@ -285,8 +353,10 @@ class It {
|
|
|
285
353
|
*
|
|
286
354
|
* @param {K} key Item's primary key
|
|
287
355
|
*/
|
|
288
|
-
delete(
|
|
289
|
-
delete this.store[
|
|
356
|
+
delete(key) {
|
|
357
|
+
delete this.store[key];
|
|
358
|
+
if (this.options.storageKey && this.options.storage)
|
|
359
|
+
this.options.storage.setItem(this.options.storageKey, JSON.stringify(this.store));
|
|
290
360
|
}
|
|
291
361
|
/**
|
|
292
362
|
* Return cache as an array of key-value pairs
|
|
@@ -300,8 +370,8 @@ class It {
|
|
|
300
370
|
* @param {K} key Key to lookup
|
|
301
371
|
* @return {T} Cached item
|
|
302
372
|
*/
|
|
303
|
-
get(
|
|
304
|
-
return this.store[
|
|
373
|
+
get(key) {
|
|
374
|
+
return this.store[key];
|
|
305
375
|
}
|
|
306
376
|
/**
|
|
307
377
|
* Get a list of cached keys
|
|
@@ -327,376 +397,444 @@ class It {
|
|
|
327
397
|
* @param {number | undefined} ttl Override default expiry in seconds
|
|
328
398
|
* @return {this}
|
|
329
399
|
*/
|
|
330
|
-
set(
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
400
|
+
set(key, value, ttl = this.options.ttl) {
|
|
401
|
+
this.store[key] = value;
|
|
402
|
+
if (this.options.storageKey && this.options.storage)
|
|
403
|
+
this.options.storage.setItem(this.options.storageKey, JSON.stringify(this.store));
|
|
404
|
+
if (ttl) setTimeout(() => {
|
|
405
|
+
this.complete = false;
|
|
406
|
+
this.delete(key);
|
|
407
|
+
}, ttl * 1e3);
|
|
408
|
+
return this;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function csv(target, flatten = true) {
|
|
412
|
+
const headers = target.reduce((acc, row) => {
|
|
413
|
+
Object.keys(flatten ? flattenObj(row) : row).forEach((key) => {
|
|
414
|
+
if (!acc.includes(key)) acc.push(key);
|
|
415
|
+
});
|
|
416
|
+
return acc;
|
|
417
|
+
}, []);
|
|
340
418
|
return [
|
|
341
|
-
|
|
342
|
-
...
|
|
343
|
-
const
|
|
344
|
-
|
|
419
|
+
headers.join(","),
|
|
420
|
+
...target.map((row) => headers.map((h) => {
|
|
421
|
+
const value = dotNotation(row, h);
|
|
422
|
+
const type = typeof value;
|
|
423
|
+
if (type == "string" && value.includes(",")) return `"${value}"`;
|
|
424
|
+
if (type == "object") return `"${JSON.stringify(value)}"`;
|
|
425
|
+
return value;
|
|
345
426
|
}).join(","))
|
|
346
|
-
].join(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
(
|
|
353
|
-
(
|
|
354
|
-
(o) => this.progress = o
|
|
427
|
+
].join("\n");
|
|
428
|
+
}
|
|
429
|
+
class PromiseProgress extends Promise {
|
|
430
|
+
constructor(executor) {
|
|
431
|
+
super((resolve, reject) => executor(
|
|
432
|
+
(value) => resolve(value),
|
|
433
|
+
(reason) => reject(reason),
|
|
434
|
+
(progress) => this.progress = progress
|
|
355
435
|
));
|
|
356
|
-
|
|
357
|
-
|
|
436
|
+
__publicField(this, "listeners", []);
|
|
437
|
+
__publicField(this, "_progress", 0);
|
|
358
438
|
}
|
|
359
439
|
get progress() {
|
|
360
440
|
return this._progress;
|
|
361
441
|
}
|
|
362
|
-
set progress(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
function
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
442
|
+
set progress(p) {
|
|
443
|
+
if (p == this._progress) return;
|
|
444
|
+
this._progress = p;
|
|
445
|
+
this.listeners.forEach((l) => l(p));
|
|
446
|
+
}
|
|
447
|
+
static from(promise) {
|
|
448
|
+
if (promise instanceof PromiseProgress) return promise;
|
|
449
|
+
return new PromiseProgress((res, rej) => promise.then((...args) => res(...args)).catch((...args) => rej(...args)));
|
|
450
|
+
}
|
|
451
|
+
from(promise) {
|
|
452
|
+
const newPromise = PromiseProgress.from(promise);
|
|
453
|
+
this.onProgress((p) => newPromise.progress = p);
|
|
454
|
+
return newPromise;
|
|
455
|
+
}
|
|
456
|
+
onProgress(callback) {
|
|
457
|
+
this.listeners.push(callback);
|
|
458
|
+
return this;
|
|
459
|
+
}
|
|
460
|
+
then(res, rej) {
|
|
461
|
+
const resp = super.then(res, rej);
|
|
462
|
+
return this.from(resp);
|
|
463
|
+
}
|
|
464
|
+
catch(rej) {
|
|
465
|
+
return this.from(super.catch(rej));
|
|
466
|
+
}
|
|
467
|
+
finally(res) {
|
|
468
|
+
return this.from(super.finally(res));
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
function downloadFile(blob, name) {
|
|
472
|
+
if (!(blob instanceof Blob)) blob = new Blob(makeArray(blob));
|
|
473
|
+
const url = URL.createObjectURL(blob);
|
|
474
|
+
downloadUrl(url, name);
|
|
475
|
+
URL.revokeObjectURL(url);
|
|
476
|
+
}
|
|
477
|
+
function downloadUrl(href, name) {
|
|
478
|
+
const a = document.createElement("a");
|
|
479
|
+
a.href = href;
|
|
480
|
+
a.download = name || href.split("/").pop();
|
|
481
|
+
document.body.appendChild(a);
|
|
482
|
+
a.click();
|
|
483
|
+
document.body.removeChild(a);
|
|
484
|
+
}
|
|
485
|
+
function fileBrowser(options = {}) {
|
|
486
|
+
return new Promise((res) => {
|
|
487
|
+
const input = document.createElement("input");
|
|
488
|
+
input.type = "file";
|
|
489
|
+
input.accept = options.accept || "*";
|
|
490
|
+
input.style.display = "none";
|
|
491
|
+
input.multiple = !!options.multiple;
|
|
492
|
+
input.onblur = input.onchange = async () => {
|
|
493
|
+
res(Array.from(input.files));
|
|
494
|
+
input.remove();
|
|
495
|
+
};
|
|
496
|
+
document.body.appendChild(input);
|
|
497
|
+
input.click();
|
|
401
498
|
});
|
|
402
499
|
}
|
|
403
|
-
function
|
|
404
|
-
(typeof
|
|
405
|
-
const
|
|
406
|
-
return
|
|
407
|
-
}
|
|
408
|
-
function
|
|
409
|
-
return new
|
|
410
|
-
const
|
|
411
|
-
|
|
500
|
+
function timestampFilename(name, date = /* @__PURE__ */ new Date()) {
|
|
501
|
+
if (typeof date == "number" || typeof date == "string") date = new Date(date);
|
|
502
|
+
const timestamp = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}_${date.getHours().toString().padStart(2, "0")}-${date.getMinutes().toString().padStart(2, "0")}-${date.getSeconds().toString().padStart(2, "0")}`;
|
|
503
|
+
return name ? name.replace("{{TIMESTAMP}}", timestamp) : timestamp;
|
|
504
|
+
}
|
|
505
|
+
function uploadWithProgress(options) {
|
|
506
|
+
return new PromiseProgress((res, rej, prog) => {
|
|
507
|
+
const xhr = new XMLHttpRequest();
|
|
508
|
+
const formData2 = new FormData();
|
|
509
|
+
options.files.forEach((f) => formData2.append("file", f));
|
|
510
|
+
xhr.withCredentials = !!options.withCredentials;
|
|
511
|
+
xhr.upload.addEventListener("progress", (event) => event.lengthComputable ? prog(event.loaded / event.total) : null);
|
|
512
|
+
xhr.addEventListener("loadend", () => res(JSONAttemptParse(xhr.responseText)));
|
|
513
|
+
xhr.addEventListener("error", () => rej(JSONAttemptParse(xhr.responseText)));
|
|
514
|
+
xhr.addEventListener("timeout", () => rej({ error: "Request timed out" }));
|
|
515
|
+
xhr.open("POST", options.url);
|
|
516
|
+
Object.entries(options.headers || {}).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
|
517
|
+
xhr.send(formData2);
|
|
412
518
|
});
|
|
413
519
|
}
|
|
414
|
-
class
|
|
520
|
+
class TypedEmitter {
|
|
415
521
|
constructor() {
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
static emit(
|
|
419
|
-
(this.listeners["*"] || []).forEach((
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
return
|
|
432
|
-
|
|
433
|
-
|
|
522
|
+
__publicField(this, "listeners", {});
|
|
523
|
+
}
|
|
524
|
+
static emit(event, ...args) {
|
|
525
|
+
(this.listeners["*"] || []).forEach((l) => l(event, ...args));
|
|
526
|
+
(this.listeners[event.toString()] || []).forEach((l) => l(...args));
|
|
527
|
+
}
|
|
528
|
+
static off(event, listener) {
|
|
529
|
+
const e = event.toString();
|
|
530
|
+
this.listeners[e] = (this.listeners[e] || []).filter((l) => l === listener);
|
|
531
|
+
}
|
|
532
|
+
static on(event, listener) {
|
|
533
|
+
var _a;
|
|
534
|
+
const e = event.toString();
|
|
535
|
+
if (!this.listeners[e]) this.listeners[e] = [];
|
|
536
|
+
(_a = this.listeners[e]) == null ? void 0 : _a.push(listener);
|
|
537
|
+
return () => this.off(event, listener);
|
|
538
|
+
}
|
|
539
|
+
static once(event, listener) {
|
|
540
|
+
return new Promise((res) => {
|
|
541
|
+
const unsubscribe = this.on(event, (...args) => {
|
|
542
|
+
res(args.length == 1 ? args[0] : args);
|
|
543
|
+
if (listener) listener(...args);
|
|
544
|
+
unsubscribe();
|
|
434
545
|
});
|
|
435
546
|
});
|
|
436
547
|
}
|
|
437
|
-
emit(
|
|
438
|
-
(this.listeners["*"] || []).forEach((
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return
|
|
449
|
-
|
|
450
|
-
|
|
548
|
+
emit(event, ...args) {
|
|
549
|
+
(this.listeners["*"] || []).forEach((l) => l(event, ...args));
|
|
550
|
+
(this.listeners[event] || []).forEach((l) => l(...args));
|
|
551
|
+
}
|
|
552
|
+
off(event, listener) {
|
|
553
|
+
this.listeners[event] = (this.listeners[event] || []).filter((l) => l === listener);
|
|
554
|
+
}
|
|
555
|
+
on(event, listener) {
|
|
556
|
+
var _a;
|
|
557
|
+
if (!this.listeners[event]) this.listeners[event] = [];
|
|
558
|
+
(_a = this.listeners[event]) == null ? void 0 : _a.push(listener);
|
|
559
|
+
return () => this.off(event, listener);
|
|
560
|
+
}
|
|
561
|
+
once(event, listener) {
|
|
562
|
+
return new Promise((res) => {
|
|
563
|
+
const unsubscribe = this.on(event, (...args) => {
|
|
564
|
+
res(args.length == 1 ? args[0] : args);
|
|
565
|
+
if (listener) listener(...args);
|
|
566
|
+
unsubscribe();
|
|
451
567
|
});
|
|
452
568
|
});
|
|
453
569
|
}
|
|
454
570
|
}
|
|
455
|
-
|
|
456
|
-
class
|
|
457
|
-
constructor(
|
|
458
|
-
super(
|
|
459
|
-
|
|
460
|
-
|
|
571
|
+
__publicField(TypedEmitter, "listeners", {});
|
|
572
|
+
class CustomError extends Error {
|
|
573
|
+
constructor(message, code) {
|
|
574
|
+
super(message);
|
|
575
|
+
__publicField(this, "_code");
|
|
576
|
+
if (code != null) this._code = code;
|
|
461
577
|
}
|
|
462
578
|
get code() {
|
|
463
579
|
return this._code || this.constructor.code;
|
|
464
580
|
}
|
|
465
|
-
set code(
|
|
466
|
-
this._code =
|
|
581
|
+
set code(c) {
|
|
582
|
+
this._code = c;
|
|
467
583
|
}
|
|
468
|
-
static from(
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
584
|
+
static from(err) {
|
|
585
|
+
const code = Number(err.statusCode) ?? Number(err.code);
|
|
586
|
+
const newErr = new this(err.message || err.toString());
|
|
587
|
+
return Object.assign(newErr, {
|
|
588
|
+
stack: err.stack,
|
|
589
|
+
...err,
|
|
590
|
+
code: code ?? void 0
|
|
474
591
|
});
|
|
475
592
|
}
|
|
476
|
-
static instanceof(
|
|
477
|
-
return
|
|
593
|
+
static instanceof(err) {
|
|
594
|
+
return err.constructor.code != void 0;
|
|
478
595
|
}
|
|
479
596
|
toString() {
|
|
480
597
|
return this.message || super.toString();
|
|
481
598
|
}
|
|
482
599
|
}
|
|
483
|
-
|
|
484
|
-
class
|
|
485
|
-
constructor(
|
|
486
|
-
super(
|
|
600
|
+
__publicField(CustomError, "code", 500);
|
|
601
|
+
class BadRequestError extends CustomError {
|
|
602
|
+
constructor(message = "Bad Request") {
|
|
603
|
+
super(message);
|
|
487
604
|
}
|
|
488
|
-
static instanceof(
|
|
489
|
-
return
|
|
605
|
+
static instanceof(err) {
|
|
606
|
+
return err.constructor.code == this.code;
|
|
490
607
|
}
|
|
491
608
|
}
|
|
492
|
-
|
|
493
|
-
class
|
|
494
|
-
constructor(
|
|
495
|
-
super(
|
|
609
|
+
__publicField(BadRequestError, "code", 400);
|
|
610
|
+
class UnauthorizedError extends CustomError {
|
|
611
|
+
constructor(message = "Unauthorized") {
|
|
612
|
+
super(message);
|
|
496
613
|
}
|
|
497
|
-
static instanceof(
|
|
498
|
-
return
|
|
614
|
+
static instanceof(err) {
|
|
615
|
+
return err.constructor.code == this.code;
|
|
499
616
|
}
|
|
500
617
|
}
|
|
501
|
-
|
|
502
|
-
class
|
|
503
|
-
constructor(
|
|
504
|
-
super(
|
|
618
|
+
__publicField(UnauthorizedError, "code", 401);
|
|
619
|
+
class PaymentRequiredError extends CustomError {
|
|
620
|
+
constructor(message = "Payment Required") {
|
|
621
|
+
super(message);
|
|
505
622
|
}
|
|
506
|
-
static instanceof(
|
|
507
|
-
return
|
|
623
|
+
static instanceof(err) {
|
|
624
|
+
return err.constructor.code == this.code;
|
|
508
625
|
}
|
|
509
626
|
}
|
|
510
|
-
|
|
511
|
-
class
|
|
512
|
-
constructor(
|
|
513
|
-
super(
|
|
627
|
+
__publicField(PaymentRequiredError, "code", 402);
|
|
628
|
+
class ForbiddenError extends CustomError {
|
|
629
|
+
constructor(message = "Forbidden") {
|
|
630
|
+
super(message);
|
|
514
631
|
}
|
|
515
|
-
static instanceof(
|
|
516
|
-
return
|
|
632
|
+
static instanceof(err) {
|
|
633
|
+
return err.constructor.code == this.code;
|
|
517
634
|
}
|
|
518
635
|
}
|
|
519
|
-
|
|
520
|
-
class
|
|
521
|
-
constructor(
|
|
522
|
-
super(
|
|
636
|
+
__publicField(ForbiddenError, "code", 403);
|
|
637
|
+
class NotFoundError extends CustomError {
|
|
638
|
+
constructor(message = "Not Found") {
|
|
639
|
+
super(message);
|
|
523
640
|
}
|
|
524
|
-
static instanceof(
|
|
525
|
-
return
|
|
641
|
+
static instanceof(err) {
|
|
642
|
+
return err.constructor.code == this.code;
|
|
526
643
|
}
|
|
527
644
|
}
|
|
528
|
-
|
|
529
|
-
class
|
|
530
|
-
constructor(
|
|
531
|
-
super(
|
|
645
|
+
__publicField(NotFoundError, "code", 404);
|
|
646
|
+
class MethodNotAllowedError extends CustomError {
|
|
647
|
+
constructor(message = "Method Not Allowed") {
|
|
648
|
+
super(message);
|
|
532
649
|
}
|
|
533
|
-
static instanceof(
|
|
534
|
-
return
|
|
650
|
+
static instanceof(err) {
|
|
651
|
+
return err.constructor.code == this.code;
|
|
535
652
|
}
|
|
536
653
|
}
|
|
537
|
-
|
|
538
|
-
class
|
|
539
|
-
constructor(
|
|
540
|
-
super(
|
|
654
|
+
__publicField(MethodNotAllowedError, "code", 405);
|
|
655
|
+
class NotAcceptableError extends CustomError {
|
|
656
|
+
constructor(message = "Not Acceptable") {
|
|
657
|
+
super(message);
|
|
541
658
|
}
|
|
542
|
-
static instanceof(
|
|
543
|
-
return
|
|
659
|
+
static instanceof(err) {
|
|
660
|
+
return err.constructor.code == this.code;
|
|
544
661
|
}
|
|
545
662
|
}
|
|
546
|
-
|
|
547
|
-
class
|
|
548
|
-
constructor(
|
|
549
|
-
super(
|
|
663
|
+
__publicField(NotAcceptableError, "code", 406);
|
|
664
|
+
class InternalServerError extends CustomError {
|
|
665
|
+
constructor(message = "Internal Server Error") {
|
|
666
|
+
super(message);
|
|
550
667
|
}
|
|
551
|
-
static instanceof(
|
|
552
|
-
return
|
|
668
|
+
static instanceof(err) {
|
|
669
|
+
return err.constructor.code == this.code;
|
|
553
670
|
}
|
|
554
671
|
}
|
|
555
|
-
|
|
556
|
-
class
|
|
557
|
-
constructor(
|
|
558
|
-
super(
|
|
672
|
+
__publicField(InternalServerError, "code", 500);
|
|
673
|
+
class NotImplementedError extends CustomError {
|
|
674
|
+
constructor(message = "Not Implemented") {
|
|
675
|
+
super(message);
|
|
559
676
|
}
|
|
560
|
-
static instanceof(
|
|
561
|
-
return
|
|
677
|
+
static instanceof(err) {
|
|
678
|
+
return err.constructor.code == this.code;
|
|
562
679
|
}
|
|
563
680
|
}
|
|
564
|
-
|
|
565
|
-
class
|
|
566
|
-
constructor(
|
|
567
|
-
super(
|
|
681
|
+
__publicField(NotImplementedError, "code", 501);
|
|
682
|
+
class BadGatewayError extends CustomError {
|
|
683
|
+
constructor(message = "Bad Gateway") {
|
|
684
|
+
super(message);
|
|
568
685
|
}
|
|
569
|
-
static instanceof(
|
|
570
|
-
return
|
|
686
|
+
static instanceof(err) {
|
|
687
|
+
return err.constructor.code == this.code;
|
|
571
688
|
}
|
|
572
689
|
}
|
|
573
|
-
|
|
574
|
-
class
|
|
575
|
-
constructor(
|
|
576
|
-
super(
|
|
690
|
+
__publicField(BadGatewayError, "code", 502);
|
|
691
|
+
class ServiceUnavailableError extends CustomError {
|
|
692
|
+
constructor(message = "Service Unavailable") {
|
|
693
|
+
super(message);
|
|
577
694
|
}
|
|
578
|
-
static instanceof(
|
|
579
|
-
return
|
|
695
|
+
static instanceof(err) {
|
|
696
|
+
return err.constructor.code == this.code;
|
|
580
697
|
}
|
|
581
698
|
}
|
|
582
|
-
|
|
583
|
-
class
|
|
584
|
-
constructor(
|
|
585
|
-
super(
|
|
699
|
+
__publicField(ServiceUnavailableError, "code", 503);
|
|
700
|
+
class GatewayTimeoutError extends CustomError {
|
|
701
|
+
constructor(message = "Gateway Timeout") {
|
|
702
|
+
super(message);
|
|
586
703
|
}
|
|
587
|
-
static instanceof(
|
|
588
|
-
return
|
|
704
|
+
static instanceof(err) {
|
|
705
|
+
return err.constructor.code == this.code;
|
|
589
706
|
}
|
|
590
707
|
}
|
|
591
|
-
|
|
592
|
-
function
|
|
593
|
-
if (
|
|
594
|
-
switch (
|
|
708
|
+
__publicField(GatewayTimeoutError, "code", 504);
|
|
709
|
+
function errorFromCode(code, message) {
|
|
710
|
+
if (code >= 200 && code < 300) return null;
|
|
711
|
+
switch (code) {
|
|
595
712
|
case 400:
|
|
596
|
-
return new
|
|
713
|
+
return new BadRequestError(message);
|
|
597
714
|
case 401:
|
|
598
|
-
return new
|
|
715
|
+
return new UnauthorizedError(message);
|
|
599
716
|
case 402:
|
|
600
|
-
return new
|
|
717
|
+
return new PaymentRequiredError(message);
|
|
601
718
|
case 403:
|
|
602
|
-
return new
|
|
719
|
+
return new ForbiddenError(message);
|
|
603
720
|
case 404:
|
|
604
|
-
return new
|
|
721
|
+
return new NotFoundError(message);
|
|
605
722
|
case 405:
|
|
606
|
-
return new
|
|
723
|
+
return new MethodNotAllowedError(message);
|
|
607
724
|
case 406:
|
|
608
|
-
return new
|
|
725
|
+
return new NotAcceptableError(message);
|
|
609
726
|
case 500:
|
|
610
|
-
return new
|
|
727
|
+
return new InternalServerError(message);
|
|
611
728
|
case 501:
|
|
612
|
-
return new
|
|
729
|
+
return new NotImplementedError(message);
|
|
613
730
|
case 502:
|
|
614
|
-
return new
|
|
731
|
+
return new BadGatewayError(message);
|
|
615
732
|
case 503:
|
|
616
|
-
return new
|
|
733
|
+
return new ServiceUnavailableError(message);
|
|
617
734
|
case 504:
|
|
618
|
-
return new
|
|
735
|
+
return new GatewayTimeoutError(message);
|
|
619
736
|
default:
|
|
620
|
-
return new
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
const
|
|
624
|
-
constructor(
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
this.url =
|
|
737
|
+
return new CustomError(message, code);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
const _Http = class _Http {
|
|
741
|
+
constructor(defaults = {}) {
|
|
742
|
+
__publicField(this, "interceptors", {});
|
|
743
|
+
__publicField(this, "headers", {});
|
|
744
|
+
__publicField(this, "url");
|
|
745
|
+
this.url = defaults.url ?? null;
|
|
746
|
+
this.headers = defaults.headers || {};
|
|
747
|
+
if (defaults.interceptors) {
|
|
748
|
+
defaults.interceptors.forEach((i) => _Http.addInterceptor(i));
|
|
749
|
+
}
|
|
629
750
|
}
|
|
630
|
-
static addInterceptor(
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
751
|
+
static addInterceptor(fn) {
|
|
752
|
+
const key = Object.keys(_Http.interceptors).length.toString();
|
|
753
|
+
_Http.interceptors[key] = fn;
|
|
754
|
+
return () => {
|
|
755
|
+
_Http.interceptors[key] = null;
|
|
634
756
|
};
|
|
635
757
|
}
|
|
636
|
-
addInterceptor(
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
|
|
758
|
+
addInterceptor(fn) {
|
|
759
|
+
const key = Object.keys(this.interceptors).length.toString();
|
|
760
|
+
this.interceptors[key] = fn;
|
|
761
|
+
return () => {
|
|
762
|
+
this.interceptors[key] = null;
|
|
640
763
|
};
|
|
641
764
|
}
|
|
642
|
-
request(
|
|
643
|
-
var
|
|
644
|
-
if (!this.url && !
|
|
645
|
-
let
|
|
646
|
-
if (
|
|
647
|
-
|
|
648
|
-
|
|
765
|
+
request(opts = {}) {
|
|
766
|
+
var _a;
|
|
767
|
+
if (!this.url && !opts.url) throw new Error("URL needs to be set");
|
|
768
|
+
let url = (((_a = opts.url) == null ? void 0 : _a.startsWith("http")) ? opts.url : (this.url || "") + (opts.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
769
|
+
if (opts.fragment) url.includes("#") ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : url += "#" + opts.fragment;
|
|
770
|
+
if (opts.query) {
|
|
771
|
+
const q = Array.isArray(opts.query) ? opts.query : Object.keys(opts.query).map((k) => ({ key: k, value: opts.query[k] }));
|
|
772
|
+
url += (url.includes("?") ? "&" : "?") + q.map((q2) => `${q2.key}=${q2.value}`).join("&");
|
|
649
773
|
}
|
|
650
|
-
const
|
|
651
|
-
"Content-Type":
|
|
652
|
-
...
|
|
774
|
+
const headers = clean({
|
|
775
|
+
"Content-Type": !opts.body ? void 0 : opts.body instanceof FormData ? "multipart/form-data" : "application/json",
|
|
776
|
+
..._Http.headers,
|
|
653
777
|
...this.headers,
|
|
654
|
-
...
|
|
778
|
+
...opts.headers
|
|
655
779
|
});
|
|
656
|
-
|
|
780
|
+
if (typeof opts.body == "object" && opts.body != null && headers["Content-Type"] == "application/json")
|
|
781
|
+
opts.body = JSON.stringify(opts.body);
|
|
782
|
+
return new PromiseProgress((res, rej, prog) => {
|
|
657
783
|
try {
|
|
658
|
-
fetch(
|
|
659
|
-
headers
|
|
660
|
-
method:
|
|
661
|
-
body:
|
|
662
|
-
}).then(async (
|
|
663
|
-
var
|
|
664
|
-
for (let
|
|
665
|
-
await new Promise((
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
784
|
+
fetch(url, {
|
|
785
|
+
headers,
|
|
786
|
+
method: opts.method || (opts.body ? "POST" : "GET"),
|
|
787
|
+
body: opts.body
|
|
788
|
+
}).then(async (resp) => {
|
|
789
|
+
var _a2, _b;
|
|
790
|
+
for (let fn of [...Object.values(_Http.interceptors), ...Object.values(this.interceptors)]) {
|
|
791
|
+
await new Promise((res2) => fn(resp, () => res2()));
|
|
792
|
+
}
|
|
793
|
+
const contentLength = resp.headers.get("Content-Length");
|
|
794
|
+
const total = contentLength ? parseInt(contentLength, 10) : 0;
|
|
795
|
+
let loaded = 0;
|
|
796
|
+
const reader = (_a2 = resp.body) == null ? void 0 : _a2.getReader();
|
|
797
|
+
const stream = new ReadableStream({
|
|
798
|
+
start(controller) {
|
|
799
|
+
function push() {
|
|
800
|
+
reader == null ? void 0 : reader.read().then((event) => {
|
|
801
|
+
if (event.done) return controller.close();
|
|
802
|
+
loaded += event.value.byteLength;
|
|
803
|
+
prog(loaded / total);
|
|
804
|
+
controller.enqueue(event.value);
|
|
805
|
+
push();
|
|
806
|
+
}).catch((error) => controller.error(error));
|
|
675
807
|
}
|
|
676
|
-
|
|
808
|
+
push();
|
|
677
809
|
}
|
|
678
810
|
});
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
811
|
+
resp.data = new Response(stream);
|
|
812
|
+
if (opts.decode == null || opts.decode) {
|
|
813
|
+
const content = (_b = resp.headers.get("Content-Type")) == null ? void 0 : _b.toLowerCase();
|
|
814
|
+
if (content == null ? void 0 : content.includes("form")) resp.data = await resp.data.formData();
|
|
815
|
+
else if (content == null ? void 0 : content.includes("json")) resp.data = await resp.data.json();
|
|
816
|
+
else if (content == null ? void 0 : content.includes("text")) resp.data = await resp.data.text();
|
|
817
|
+
else if (content == null ? void 0 : content.includes("application")) resp.data = await resp.data.blob();
|
|
682
818
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
819
|
+
if (resp.ok) res(resp);
|
|
820
|
+
else rej(resp);
|
|
821
|
+
}).catch((err) => rej(err));
|
|
822
|
+
} catch (err) {
|
|
823
|
+
rej(err);
|
|
687
824
|
}
|
|
688
825
|
});
|
|
689
826
|
}
|
|
690
827
|
};
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
828
|
+
__publicField(_Http, "interceptors", {});
|
|
829
|
+
__publicField(_Http, "headers", {});
|
|
830
|
+
let Http = _Http;
|
|
831
|
+
function jwtDecode(token) {
|
|
832
|
+
const base64 = token.split(".")[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
833
|
+
return JSONAttemptParse(decodeURIComponent(atob(base64).split("").map(function(c) {
|
|
834
|
+
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
|
697
835
|
}).join("")));
|
|
698
836
|
}
|
|
699
|
-
const
|
|
837
|
+
const CliEffects = {
|
|
700
838
|
CLEAR: "\x1B[0m",
|
|
701
839
|
BRIGHT: "\x1B[1m",
|
|
702
840
|
DIM: "\x1B[2m",
|
|
@@ -704,7 +842,8 @@ const R = {
|
|
|
704
842
|
BLINK: "\x1B[5m",
|
|
705
843
|
REVERSE: "\x1B[7m",
|
|
706
844
|
HIDDEN: "\x1B[8m"
|
|
707
|
-
}
|
|
845
|
+
};
|
|
846
|
+
const CliForeground = {
|
|
708
847
|
BLACK: "\x1B[30m",
|
|
709
848
|
RED: "\x1B[31m",
|
|
710
849
|
GREEN: "\x1B[32m",
|
|
@@ -721,7 +860,8 @@ const R = {
|
|
|
721
860
|
LIGHT_MAGENTA: "\x1B[95m",
|
|
722
861
|
LIGHT_CYAN: "\x1B[96m",
|
|
723
862
|
WHITE: "\x1B[97m"
|
|
724
|
-
}
|
|
863
|
+
};
|
|
864
|
+
const CliBackground = {
|
|
725
865
|
BLACK: "\x1B[40m",
|
|
726
866
|
RED: "\x1B[41m",
|
|
727
867
|
GREEN: "\x1B[42m",
|
|
@@ -732,246 +872,307 @@ const R = {
|
|
|
732
872
|
WHITE: "\x1B[47m",
|
|
733
873
|
GREY: "\x1B[100m"
|
|
734
874
|
};
|
|
735
|
-
var
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
if (
|
|
761
|
-
const
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
875
|
+
var LOG_LEVEL = /* @__PURE__ */ ((LOG_LEVEL2) => {
|
|
876
|
+
LOG_LEVEL2[LOG_LEVEL2["ERROR"] = 0] = "ERROR";
|
|
877
|
+
LOG_LEVEL2[LOG_LEVEL2["WARN"] = 1] = "WARN";
|
|
878
|
+
LOG_LEVEL2[LOG_LEVEL2["INFO"] = 2] = "INFO";
|
|
879
|
+
LOG_LEVEL2[LOG_LEVEL2["LOG"] = 3] = "LOG";
|
|
880
|
+
LOG_LEVEL2[LOG_LEVEL2["DEBUG"] = 4] = "DEBUG";
|
|
881
|
+
return LOG_LEVEL2;
|
|
882
|
+
})(LOG_LEVEL || {});
|
|
883
|
+
const _Logger = class _Logger extends TypedEmitter {
|
|
884
|
+
constructor(namespace) {
|
|
885
|
+
super();
|
|
886
|
+
this.namespace = namespace;
|
|
887
|
+
}
|
|
888
|
+
format(...text) {
|
|
889
|
+
const now = /* @__PURE__ */ new Date();
|
|
890
|
+
const timestamp = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()} ${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}.${now.getMilliseconds().toString().padEnd(3, "0")}`;
|
|
891
|
+
return `${timestamp}${this.namespace ? ` [${this.namespace}]` : ""} ${text.map((t) => typeof t == "string" ? t : JSONSanitize(t, 2)).join(" ")}`;
|
|
892
|
+
}
|
|
893
|
+
debug(...args) {
|
|
894
|
+
if (_Logger.LOG_LEVEL < 4) return;
|
|
895
|
+
const str = this.format(...args);
|
|
896
|
+
_Logger.emit(4, str);
|
|
897
|
+
console.debug(CliForeground.LIGHT_GREY + str + CliEffects.CLEAR);
|
|
898
|
+
}
|
|
899
|
+
log(...args) {
|
|
900
|
+
if (_Logger.LOG_LEVEL < 3) return;
|
|
901
|
+
const str = this.format(...args);
|
|
902
|
+
_Logger.emit(3, str);
|
|
903
|
+
console.log(CliEffects.CLEAR + str);
|
|
904
|
+
}
|
|
905
|
+
info(...args) {
|
|
906
|
+
if (_Logger.LOG_LEVEL < 2) return;
|
|
907
|
+
const str = this.format(...args);
|
|
908
|
+
_Logger.emit(2, str);
|
|
909
|
+
console.info(CliForeground.BLUE + str + CliEffects.CLEAR);
|
|
910
|
+
}
|
|
911
|
+
warn(...args) {
|
|
912
|
+
if (_Logger.LOG_LEVEL < 1) return;
|
|
913
|
+
const str = this.format(...args);
|
|
914
|
+
_Logger.emit(1, str);
|
|
915
|
+
console.warn(CliForeground.YELLOW + str + CliEffects.CLEAR);
|
|
916
|
+
}
|
|
917
|
+
error(...args) {
|
|
918
|
+
if (_Logger.LOG_LEVEL < 0) return;
|
|
919
|
+
const str = this.format(...args);
|
|
920
|
+
_Logger.emit(0, str);
|
|
921
|
+
console.error(CliForeground.RED + str + CliEffects.CLEAR);
|
|
768
922
|
}
|
|
769
923
|
};
|
|
770
|
-
|
|
771
|
-
let
|
|
772
|
-
function
|
|
773
|
-
const
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
const
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
924
|
+
__publicField(_Logger, "LOG_LEVEL", 4);
|
|
925
|
+
let Logger = _Logger;
|
|
926
|
+
function dec2Frac(num) {
|
|
927
|
+
const gcd = (a, b) => {
|
|
928
|
+
if (b < 1e-7) return a;
|
|
929
|
+
return gcd(b, ~~(a % b));
|
|
930
|
+
};
|
|
931
|
+
const len = num.toString().length - 2;
|
|
932
|
+
let denominator = Math.pow(10, len);
|
|
933
|
+
let numerator = num * denominator;
|
|
934
|
+
const divisor = gcd(numerator, denominator);
|
|
935
|
+
numerator = ~~(numerator / divisor);
|
|
936
|
+
denominator = ~~(denominator / divisor);
|
|
937
|
+
const remainder = ~~(numerator / denominator);
|
|
938
|
+
numerator -= remainder * denominator;
|
|
939
|
+
return `${remainder ? remainder + " " : ""}${~~numerator}/${~~denominator}`;
|
|
940
|
+
}
|
|
941
|
+
function fracToDec(frac) {
|
|
942
|
+
let split = frac.split(" ");
|
|
943
|
+
const whole = split.length == 2 ? Number(split[0]) : 0;
|
|
944
|
+
split = split.pop().split("/");
|
|
945
|
+
return whole + Number(split[0]) / Number(split[1]);
|
|
946
|
+
}
|
|
947
|
+
const LETTER_LIST = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
948
|
+
const NUMBER_LIST = "0123456789";
|
|
949
|
+
const SYMBOL_LIST = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/";
|
|
950
|
+
const CHAR_LIST = LETTER_LIST + NUMBER_LIST + SYMBOL_LIST;
|
|
951
|
+
function formatBytes(bytes, decimals = 2) {
|
|
952
|
+
if (bytes === 0) return "0 Bytes";
|
|
953
|
+
const k = 1024;
|
|
954
|
+
const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
|
955
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
956
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(decimals)) + " " + sizes[i];
|
|
957
|
+
}
|
|
958
|
+
function formatPhoneNumber(number) {
|
|
959
|
+
const parts = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(number);
|
|
960
|
+
if (!parts) throw new Error(`Number cannot be parsed: ${number}`);
|
|
961
|
+
return `${parts[1] ?? ""} (${parts[2]}) ${parts[3]}-${parts[4]}`.trim();
|
|
962
|
+
}
|
|
963
|
+
function insertAt(target, str, index) {
|
|
964
|
+
return `${target.slice(0, index)}${str}${target.slice(index + 1)}`;
|
|
965
|
+
}
|
|
966
|
+
function pad(text, length, char = " ", start = true) {
|
|
967
|
+
if (start) return text.toString().padStart(length, char);
|
|
968
|
+
return text.toString().padEnd(length, char);
|
|
969
|
+
}
|
|
970
|
+
function randomHex(length) {
|
|
971
|
+
return Array(length).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
|
|
972
|
+
}
|
|
973
|
+
function randomString(length, pool = CHAR_LIST) {
|
|
974
|
+
return Array(length).fill(null).map(() => {
|
|
975
|
+
const n = ~~(Math.random() * pool.length);
|
|
976
|
+
return pool[n];
|
|
809
977
|
}).join("");
|
|
810
978
|
}
|
|
811
|
-
function
|
|
812
|
-
if (!
|
|
813
|
-
return Array(
|
|
814
|
-
let
|
|
979
|
+
function randomStringBuilder(length, letters = false, numbers = false, symbols = false) {
|
|
980
|
+
if (!letters && !numbers && !symbols) throw new Error("Must enable at least one: letters, numbers, symbols");
|
|
981
|
+
return Array(length).fill(null).map(() => {
|
|
982
|
+
let c;
|
|
815
983
|
do {
|
|
816
|
-
const
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
984
|
+
const type = ~~(Math.random() * 3);
|
|
985
|
+
if (letters && type == 0) {
|
|
986
|
+
c = LETTER_LIST[~~(Math.random() * LETTER_LIST.length)];
|
|
987
|
+
} else if (numbers && type == 1) {
|
|
988
|
+
c = NUMBER_LIST[~~(Math.random() * NUMBER_LIST.length)];
|
|
989
|
+
} else if (symbols && type == 2) {
|
|
990
|
+
c = SYMBOL_LIST[~~(Math.random() * SYMBOL_LIST.length)];
|
|
991
|
+
}
|
|
992
|
+
} while (!c);
|
|
993
|
+
return c;
|
|
820
994
|
}).join("");
|
|
821
995
|
}
|
|
822
|
-
function
|
|
823
|
-
if (typeof
|
|
996
|
+
function matchAll(value, regex) {
|
|
997
|
+
if (typeof regex === "string") {
|
|
998
|
+
regex = new RegExp(regex, "g");
|
|
999
|
+
}
|
|
1000
|
+
if (!regex.global) {
|
|
824
1001
|
throw new TypeError("Regular expression must be global.");
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
1002
|
+
}
|
|
1003
|
+
let ret = [];
|
|
1004
|
+
let match;
|
|
1005
|
+
while ((match = regex.exec(value)) !== null) {
|
|
1006
|
+
ret.push(match);
|
|
1007
|
+
}
|
|
1008
|
+
return ret;
|
|
829
1009
|
}
|
|
830
|
-
function
|
|
831
|
-
const
|
|
1010
|
+
function parseUrl(url) {
|
|
1011
|
+
const processed = new RegExp(
|
|
832
1012
|
"(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
|
|
833
1013
|
"gm"
|
|
834
|
-
).exec(
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
1014
|
+
).exec(url);
|
|
1015
|
+
const groups = (processed == null ? void 0 : processed.groups) ?? {};
|
|
1016
|
+
const domains = groups.domain.split(".");
|
|
1017
|
+
if (groups["port"] != null) groups.port = Number(groups.port);
|
|
1018
|
+
if (domains.length > 2) {
|
|
1019
|
+
groups.domain = domains.splice(-2, 2).join(".");
|
|
1020
|
+
groups.subdomain = domains.join(".");
|
|
1021
|
+
}
|
|
1022
|
+
if (groups.query) {
|
|
1023
|
+
const split = groups.query.split("&"), query = {};
|
|
1024
|
+
split.forEach((q) => {
|
|
1025
|
+
const [key, val] = q.split("=");
|
|
1026
|
+
query[key] = val;
|
|
1027
|
+
});
|
|
1028
|
+
groups.query = query;
|
|
841
1029
|
}
|
|
842
|
-
return
|
|
1030
|
+
return groups;
|
|
843
1031
|
}
|
|
844
|
-
function
|
|
845
|
-
var
|
|
846
|
-
return
|
|
1032
|
+
function md5(d) {
|
|
1033
|
+
var r = M(V(Y(X(d), 8 * d.length)));
|
|
1034
|
+
return r.toLowerCase();
|
|
847
1035
|
}
|
|
848
|
-
function
|
|
849
|
-
for (var
|
|
850
|
-
return
|
|
1036
|
+
function M(d) {
|
|
1037
|
+
for (var _, m = "0123456789ABCDEF", f = "", r = 0; r < d.length; r++) _ = d.charCodeAt(r), f += m.charAt(_ >>> 4 & 15) + m.charAt(15 & _);
|
|
1038
|
+
return f;
|
|
851
1039
|
}
|
|
852
|
-
function
|
|
853
|
-
for (var
|
|
854
|
-
for (
|
|
855
|
-
return
|
|
1040
|
+
function X(d) {
|
|
1041
|
+
for (var _ = Array(d.length >> 2), m = 0; m < _.length; m++) _[m] = 0;
|
|
1042
|
+
for (m = 0; m < 8 * d.length; m += 8) _[m >> 5] |= (255 & d.charCodeAt(m / 8)) << m % 32;
|
|
1043
|
+
return _;
|
|
856
1044
|
}
|
|
857
|
-
function
|
|
858
|
-
for (var
|
|
859
|
-
return
|
|
1045
|
+
function V(d) {
|
|
1046
|
+
for (var _ = "", m = 0; m < 32 * d.length; m += 8) _ += String.fromCharCode(d[m >> 5] >>> m % 32 & 255);
|
|
1047
|
+
return _;
|
|
860
1048
|
}
|
|
861
|
-
function
|
|
862
|
-
|
|
863
|
-
for (var
|
|
864
|
-
var
|
|
865
|
-
|
|
1049
|
+
function Y(d, _) {
|
|
1050
|
+
d[_ >> 5] |= 128 << _ % 32, d[14 + (_ + 64 >>> 9 << 4)] = _;
|
|
1051
|
+
for (var m = 1732584193, f = -271733879, r = -1732584194, i = 271733878, n = 0; n < d.length; n += 16) {
|
|
1052
|
+
var h = m, t = f, g = r, e = i;
|
|
1053
|
+
f = md5_ii(f = md5_ii(f = md5_ii(f = md5_ii(f = md5_hh(f = md5_hh(f = md5_hh(f = md5_hh(f = md5_gg(f = md5_gg(f = md5_gg(f = md5_gg(f = md5_ff(f = md5_ff(f = md5_ff(f = md5_ff(f, r = md5_ff(r, i = md5_ff(i, m = md5_ff(m, f, r, i, d[n + 0], 7, -680876936), f, r, d[n + 1], 12, -389564586), m, f, d[n + 2], 17, 606105819), i, m, d[n + 3], 22, -1044525330), r = md5_ff(r, i = md5_ff(i, m = md5_ff(m, f, r, i, d[n + 4], 7, -176418897), f, r, d[n + 5], 12, 1200080426), m, f, d[n + 6], 17, -1473231341), i, m, d[n + 7], 22, -45705983), r = md5_ff(r, i = md5_ff(i, m = md5_ff(m, f, r, i, d[n + 8], 7, 1770035416), f, r, d[n + 9], 12, -1958414417), m, f, d[n + 10], 17, -42063), i, m, d[n + 11], 22, -1990404162), r = md5_ff(r, i = md5_ff(i, m = md5_ff(m, f, r, i, d[n + 12], 7, 1804603682), f, r, d[n + 13], 12, -40341101), m, f, d[n + 14], 17, -1502002290), i, m, d[n + 15], 22, 1236535329), r = md5_gg(r, i = md5_gg(i, m = md5_gg(m, f, r, i, d[n + 1], 5, -165796510), f, r, d[n + 6], 9, -1069501632), m, f, d[n + 11], 14, 643717713), i, m, d[n + 0], 20, -373897302), r = md5_gg(r, i = md5_gg(i, m = md5_gg(m, f, r, i, d[n + 5], 5, -701558691), f, r, d[n + 10], 9, 38016083), m, f, d[n + 15], 14, -660478335), i, m, d[n + 4], 20, -405537848), r = md5_gg(r, i = md5_gg(i, m = md5_gg(m, f, r, i, d[n + 9], 5, 568446438), f, r, d[n + 14], 9, -1019803690), m, f, d[n + 3], 14, -187363961), i, m, d[n + 8], 20, 1163531501), r = md5_gg(r, i = md5_gg(i, m = md5_gg(m, f, r, i, d[n + 13], 5, -1444681467), f, r, d[n + 2], 9, -51403784), m, f, d[n + 7], 14, 1735328473), i, m, d[n + 12], 20, -1926607734), r = md5_hh(r, i = md5_hh(i, m = md5_hh(m, f, r, i, d[n + 5], 4, -378558), f, r, d[n + 8], 11, -2022574463), m, f, d[n + 11], 16, 1839030562), i, m, d[n + 14], 23, -35309556), r = md5_hh(r, i = md5_hh(i, m = md5_hh(m, f, r, i, d[n + 1], 4, -1530992060), f, r, d[n + 4], 11, 1272893353), m, f, d[n + 7], 16, -155497632), i, m, d[n + 10], 23, -1094730640), r = md5_hh(r, i = md5_hh(i, m = md5_hh(m, f, r, i, d[n + 13], 4, 681279174), f, r, d[n + 0], 11, -358537222), m, f, d[n + 3], 16, -722521979), i, m, d[n + 6], 23, 76029189), r = md5_hh(r, i = md5_hh(i, m = md5_hh(m, f, r, i, d[n + 9], 4, -640364487), f, r, d[n + 12], 11, -421815835), m, f, d[n + 15], 16, 530742520), i, m, d[n + 2], 23, -995338651), r = md5_ii(r, i = md5_ii(i, m = md5_ii(m, f, r, i, d[n + 0], 6, -198630844), f, r, d[n + 7], 10, 1126891415), m, f, d[n + 14], 15, -1416354905), i, m, d[n + 5], 21, -57434055), r = md5_ii(r, i = md5_ii(i, m = md5_ii(m, f, r, i, d[n + 12], 6, 1700485571), f, r, d[n + 3], 10, -1894986606), m, f, d[n + 10], 15, -1051523), i, m, d[n + 1], 21, -2054922799), r = md5_ii(r, i = md5_ii(i, m = md5_ii(m, f, r, i, d[n + 8], 6, 1873313359), f, r, d[n + 15], 10, -30611744), m, f, d[n + 6], 15, -1560198380), i, m, d[n + 13], 21, 1309151649), r = md5_ii(r, i = md5_ii(i, m = md5_ii(m, f, r, i, d[n + 4], 6, -145523070), f, r, d[n + 11], 10, -1120210379), m, f, d[n + 2], 15, 718787259), i, m, d[n + 9], 21, -343485551), m = safe_add(m, h), f = safe_add(f, t), r = safe_add(r, g), i = safe_add(i, e);
|
|
866
1054
|
}
|
|
867
|
-
return Array(
|
|
1055
|
+
return Array(m, f, r, i);
|
|
868
1056
|
}
|
|
869
|
-
function
|
|
870
|
-
return
|
|
1057
|
+
function md5_cmn(d, _, m, f, r, i) {
|
|
1058
|
+
return safe_add(bit_rol(safe_add(safe_add(_, d), safe_add(f, i)), r), m);
|
|
871
1059
|
}
|
|
872
|
-
function
|
|
873
|
-
return
|
|
1060
|
+
function md5_ff(d, _, m, f, r, i, n) {
|
|
1061
|
+
return md5_cmn(_ & m | ~_ & f, d, _, r, i, n);
|
|
874
1062
|
}
|
|
875
|
-
function
|
|
876
|
-
return
|
|
1063
|
+
function md5_gg(d, _, m, f, r, i, n) {
|
|
1064
|
+
return md5_cmn(_ & f | m & ~f, d, _, r, i, n);
|
|
877
1065
|
}
|
|
878
|
-
function d
|
|
879
|
-
return
|
|
1066
|
+
function md5_hh(d, _, m, f, r, i, n) {
|
|
1067
|
+
return md5_cmn(_ ^ m ^ f, d, _, r, i, n);
|
|
880
1068
|
}
|
|
881
|
-
function
|
|
882
|
-
return
|
|
1069
|
+
function md5_ii(d, _, m, f, r, i, n) {
|
|
1070
|
+
return md5_cmn(m ^ (_ | ~f), d, _, r, i, n);
|
|
883
1071
|
}
|
|
884
|
-
function
|
|
885
|
-
var
|
|
886
|
-
return (
|
|
1072
|
+
function safe_add(d, _) {
|
|
1073
|
+
var m = (65535 & d) + (65535 & _);
|
|
1074
|
+
return (d >> 16) + (_ >> 16) + (m >> 16) << 16 | 65535 & m;
|
|
887
1075
|
}
|
|
888
|
-
function
|
|
889
|
-
return
|
|
1076
|
+
function bit_rol(d, _) {
|
|
1077
|
+
return d << _ | d >>> 32 - _;
|
|
890
1078
|
}
|
|
891
|
-
function
|
|
892
|
-
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
|
|
1079
|
+
function validateEmail(email) {
|
|
1080
|
+
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(email);
|
|
893
1081
|
}
|
|
894
|
-
function
|
|
895
|
-
|
|
1082
|
+
function gravatar(email, def = "mp") {
|
|
1083
|
+
if (!email) return "";
|
|
1084
|
+
return `https://www.gravatar.com/avatar/${md5(email)}?d=${def}`;
|
|
896
1085
|
}
|
|
897
|
-
function
|
|
898
|
-
return
|
|
1086
|
+
function escapeRegex(value) {
|
|
1087
|
+
return value.replace(/[.*+?^${}()|\[\]\\]/g, "\\$&");
|
|
899
1088
|
}
|
|
900
|
-
function
|
|
901
|
-
const
|
|
902
|
-
for (let
|
|
903
|
-
|
|
904
|
-
|
|
1089
|
+
function PE(str, ...args) {
|
|
1090
|
+
const combined = [];
|
|
1091
|
+
for (let i = 0; i < str.length || i < args.length; i++) {
|
|
1092
|
+
if (str[i]) combined.push(str[i]);
|
|
1093
|
+
if (args[i]) combined.push(args[i]);
|
|
1094
|
+
}
|
|
1095
|
+
return new PathEvent(combined.join(""));
|
|
905
1096
|
}
|
|
906
|
-
function
|
|
907
|
-
let
|
|
908
|
-
for (let
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
1097
|
+
function PES(str, ...args) {
|
|
1098
|
+
let combined = [];
|
|
1099
|
+
for (let i = 0; i < str.length || i < args.length; i++) {
|
|
1100
|
+
if (str[i]) combined.push(str[i]);
|
|
1101
|
+
if (args[i]) combined.push(args[i]);
|
|
1102
|
+
}
|
|
1103
|
+
const [paths, methods] = combined.join("").split(":");
|
|
1104
|
+
return PathEvent.toString(paths, methods == null ? void 0 : methods.split(""));
|
|
912
1105
|
}
|
|
913
|
-
class
|
|
1106
|
+
class PathError extends Error {
|
|
914
1107
|
}
|
|
915
|
-
class
|
|
916
|
-
constructor(
|
|
1108
|
+
class PathEvent {
|
|
1109
|
+
constructor(Event) {
|
|
917
1110
|
/** First directory in path */
|
|
918
|
-
|
|
1111
|
+
__publicField(this, "module");
|
|
919
1112
|
/** Entire path, including the module & name */
|
|
920
|
-
|
|
1113
|
+
__publicField(this, "fullPath");
|
|
921
1114
|
/** Path including the name, excluding the module */
|
|
922
|
-
|
|
1115
|
+
__publicField(this, "path");
|
|
923
1116
|
/** Last sagment of path */
|
|
924
|
-
|
|
1117
|
+
__publicField(this, "name");
|
|
925
1118
|
/** List of methods */
|
|
926
|
-
|
|
927
|
-
var
|
|
928
|
-
if (typeof
|
|
929
|
-
let [
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
1119
|
+
__publicField(this, "methods");
|
|
1120
|
+
var _a;
|
|
1121
|
+
if (typeof Event == "object") return Object.assign(this, Event);
|
|
1122
|
+
let [p, scope, method] = Event.split(":");
|
|
1123
|
+
if (!method) method = scope || "*";
|
|
1124
|
+
if (p == "*" || !p && method == "*") {
|
|
1125
|
+
p = "";
|
|
1126
|
+
method = "*";
|
|
1127
|
+
}
|
|
1128
|
+
let temp = p.split("/").filter((p2) => !!p2);
|
|
1129
|
+
this.module = ((_a = temp.splice(0, 1)[0]) == null ? void 0 : _a.toLowerCase()) || "";
|
|
1130
|
+
this.fullPath = p;
|
|
1131
|
+
this.path = temp.join("/");
|
|
1132
|
+
this.name = temp.pop() || "";
|
|
1133
|
+
this.methods = new ASet(method.split(""));
|
|
933
1134
|
}
|
|
934
1135
|
/** All/Wildcard specified */
|
|
935
1136
|
get all() {
|
|
936
1137
|
return this.methods.has("*");
|
|
937
1138
|
}
|
|
938
|
-
set all(
|
|
939
|
-
|
|
1139
|
+
set all(v) {
|
|
1140
|
+
v ? new ASet(["*"]) : this.methods.delete("*");
|
|
940
1141
|
}
|
|
941
1142
|
/** None specified */
|
|
942
1143
|
get none() {
|
|
943
1144
|
return this.methods.has("n");
|
|
944
1145
|
}
|
|
945
|
-
set none(
|
|
946
|
-
|
|
1146
|
+
set none(v) {
|
|
1147
|
+
v ? this.methods = new ASet(["n"]) : this.methods.delete("n");
|
|
947
1148
|
}
|
|
948
1149
|
/** Create method specified */
|
|
949
1150
|
get create() {
|
|
950
1151
|
return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("c"));
|
|
951
1152
|
}
|
|
952
|
-
set create(
|
|
953
|
-
|
|
1153
|
+
set create(v) {
|
|
1154
|
+
v ? this.methods.delete("n").add("c") : this.methods.delete("c");
|
|
954
1155
|
}
|
|
955
1156
|
/** Read method specified */
|
|
956
1157
|
get read() {
|
|
957
1158
|
return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("r"));
|
|
958
1159
|
}
|
|
959
|
-
set read(
|
|
960
|
-
|
|
1160
|
+
set read(v) {
|
|
1161
|
+
v ? this.methods.delete("n").add("r") : this.methods.delete("r");
|
|
961
1162
|
}
|
|
962
1163
|
/** Update method specified */
|
|
963
1164
|
get update() {
|
|
964
1165
|
return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("u"));
|
|
965
1166
|
}
|
|
966
|
-
set update(
|
|
967
|
-
|
|
1167
|
+
set update(v) {
|
|
1168
|
+
v ? this.methods.delete("n").add("u") : this.methods.delete("u");
|
|
968
1169
|
}
|
|
969
1170
|
/** Delete method specified */
|
|
970
1171
|
get delete() {
|
|
971
1172
|
return !this.methods.has("n") && (this.methods.has("*") || this.methods.has("d"));
|
|
972
1173
|
}
|
|
973
|
-
set delete(
|
|
974
|
-
|
|
1174
|
+
set delete(v) {
|
|
1175
|
+
v ? this.methods.delete("n").add("d") : this.methods.delete("d");
|
|
975
1176
|
}
|
|
976
1177
|
/**
|
|
977
1178
|
* Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
|
|
@@ -980,13 +1181,20 @@ class g {
|
|
|
980
1181
|
* @param {string | PathEvent} paths Events as strings or pre-parsed
|
|
981
1182
|
* @return {PathEvent} Final combined permission
|
|
982
1183
|
*/
|
|
983
|
-
static combine(...
|
|
984
|
-
let
|
|
985
|
-
const
|
|
986
|
-
const
|
|
987
|
-
return
|
|
988
|
-
}).reduce((
|
|
989
|
-
|
|
1184
|
+
static combine(...paths) {
|
|
1185
|
+
let hitNone = false;
|
|
1186
|
+
const combined = paths.map((p) => new PathEvent(p)).toSorted((p1, p2) => {
|
|
1187
|
+
const l1 = p1.fullPath.length, l2 = p2.fullPath.length;
|
|
1188
|
+
return l1 < l2 ? 1 : l1 > l2 ? -1 : 0;
|
|
1189
|
+
}).reduce((acc, p) => {
|
|
1190
|
+
if (p.none) hitNone = true;
|
|
1191
|
+
if (!acc) return p;
|
|
1192
|
+
if (hitNone) return acc;
|
|
1193
|
+
acc.methods = [...acc.methods, ...p.methods];
|
|
1194
|
+
return acc;
|
|
1195
|
+
}, null);
|
|
1196
|
+
combined.methods = new ASet(combined.methods);
|
|
1197
|
+
return combined;
|
|
990
1198
|
}
|
|
991
1199
|
/**
|
|
992
1200
|
* Squash 2 sets of paths & return true if any overlap is found
|
|
@@ -995,14 +1203,15 @@ class g {
|
|
|
995
1203
|
* @param has Target must have at least one of these path
|
|
996
1204
|
* @return {boolean} Whether there is any overlap
|
|
997
1205
|
*/
|
|
998
|
-
static has(
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1206
|
+
static has(target, ...has) {
|
|
1207
|
+
const parsedRequired = makeArray(has).map((pe) => new PathEvent(pe));
|
|
1208
|
+
const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
|
|
1209
|
+
return !!parsedRequired.find((r) => {
|
|
1210
|
+
if (!r.fullPath && r.all) return true;
|
|
1211
|
+
const filtered = parsedTarget.filter((p) => r.fullPath.startsWith(p.fullPath));
|
|
1212
|
+
if (!filtered.length) return false;
|
|
1213
|
+
const combined = PathEvent.combine(...filtered);
|
|
1214
|
+
return !combined.none && (combined.all || new ASet(combined.methods).intersection(new ASet(r.methods)).length);
|
|
1006
1215
|
});
|
|
1007
1216
|
}
|
|
1008
1217
|
/**
|
|
@@ -1012,8 +1221,8 @@ class g {
|
|
|
1012
1221
|
* @param has Target must have all these paths
|
|
1013
1222
|
* @return {boolean} Whether there is any overlap
|
|
1014
1223
|
*/
|
|
1015
|
-
static hasAll(
|
|
1016
|
-
return
|
|
1224
|
+
static hasAll(target, ...has) {
|
|
1225
|
+
return has.filter((h) => PathEvent.has(target, h)).length == has.length;
|
|
1017
1226
|
}
|
|
1018
1227
|
/**
|
|
1019
1228
|
* Same as `has` but raises an error if there is no overlap
|
|
@@ -1021,8 +1230,8 @@ class g {
|
|
|
1021
1230
|
* @param {string | string[]} target Array of Events as strings or pre-parsed
|
|
1022
1231
|
* @param has Target must have at least one of these path
|
|
1023
1232
|
*/
|
|
1024
|
-
static hasFatal(
|
|
1025
|
-
if (!
|
|
1233
|
+
static hasFatal(target, ...has) {
|
|
1234
|
+
if (!PathEvent.has(target, ...has)) throw new PathError(`Requires one of: ${makeArray(has).join(", ")}`);
|
|
1026
1235
|
}
|
|
1027
1236
|
/**
|
|
1028
1237
|
* Same as `hasAll` but raises an error if the target is missing any paths
|
|
@@ -1030,8 +1239,8 @@ class g {
|
|
|
1030
1239
|
* @param {string | string[]} target Array of Events as strings or pre-parsed
|
|
1031
1240
|
* @param has Target must have all these paths
|
|
1032
1241
|
*/
|
|
1033
|
-
static hasAllFatal(
|
|
1034
|
-
if (!
|
|
1242
|
+
static hasAllFatal(target, ...has) {
|
|
1243
|
+
if (!PathEvent.hasAll(target, ...has)) throw new PathError(`Requires all: ${makeArray(has).join(", ")}`);
|
|
1035
1244
|
}
|
|
1036
1245
|
/**
|
|
1037
1246
|
* Create event string from its components
|
|
@@ -1040,9 +1249,11 @@ class g {
|
|
|
1040
1249
|
* @param {Method} methods Event method
|
|
1041
1250
|
* @return {string} String representation of Event
|
|
1042
1251
|
*/
|
|
1043
|
-
static toString(
|
|
1044
|
-
let
|
|
1045
|
-
|
|
1252
|
+
static toString(path, methods) {
|
|
1253
|
+
let p = makeArray(path).filter((p2) => p2 != null).join("/");
|
|
1254
|
+
p = p == null ? void 0 : p.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
|
|
1255
|
+
if (methods == null ? void 0 : methods.length) p += `:${makeArray(methods).map((m) => m.toLowerCase()).join("")}`;
|
|
1256
|
+
return p;
|
|
1046
1257
|
}
|
|
1047
1258
|
/**
|
|
1048
1259
|
* Create event string from its components
|
|
@@ -1050,127 +1261,134 @@ class g {
|
|
|
1050
1261
|
* @return {string} String representation of Event
|
|
1051
1262
|
*/
|
|
1052
1263
|
toString() {
|
|
1053
|
-
return
|
|
1264
|
+
return PathEvent.toString(this.fullPath, this.methods);
|
|
1054
1265
|
}
|
|
1055
1266
|
}
|
|
1056
|
-
class
|
|
1267
|
+
class PathEventEmitter {
|
|
1057
1268
|
constructor() {
|
|
1058
|
-
|
|
1269
|
+
__publicField(this, "listeners", []);
|
|
1059
1270
|
}
|
|
1060
|
-
emit(
|
|
1061
|
-
const
|
|
1062
|
-
this.listeners.filter((
|
|
1271
|
+
emit(event, ...args) {
|
|
1272
|
+
const parsed = new PathEvent(event);
|
|
1273
|
+
this.listeners.filter((l) => PathEvent.has(l[0], event)).forEach(async (l) => l[1](parsed, ...args));
|
|
1063
1274
|
}
|
|
1064
|
-
off(
|
|
1065
|
-
this.listeners = this.listeners.filter((
|
|
1275
|
+
off(listener) {
|
|
1276
|
+
this.listeners = this.listeners.filter((l) => l[1] != listener);
|
|
1066
1277
|
}
|
|
1067
|
-
on(
|
|
1068
|
-
|
|
1278
|
+
on(event, listener) {
|
|
1279
|
+
makeArray(event).forEach((e) => this.listeners.push([new PathEvent(e), listener]));
|
|
1280
|
+
return () => this.off(listener);
|
|
1069
1281
|
}
|
|
1070
|
-
once(
|
|
1071
|
-
return new Promise((
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1282
|
+
once(event, listener) {
|
|
1283
|
+
return new Promise((res) => {
|
|
1284
|
+
const unsubscribe = this.on(event, (event2, ...args) => {
|
|
1285
|
+
res(args.length < 2 ? args[0] : args);
|
|
1286
|
+
if (listener) listener(event2, ...args);
|
|
1287
|
+
unsubscribe();
|
|
1074
1288
|
});
|
|
1075
1289
|
});
|
|
1076
1290
|
}
|
|
1077
|
-
relayEvents(
|
|
1078
|
-
|
|
1291
|
+
relayEvents(emitter) {
|
|
1292
|
+
emitter.on("*", (event, ...args) => this.emit(event, ...args));
|
|
1079
1293
|
}
|
|
1080
1294
|
}
|
|
1081
|
-
function
|
|
1082
|
-
(typeof
|
|
1083
|
-
let
|
|
1084
|
-
|
|
1295
|
+
function formatDate(date) {
|
|
1296
|
+
if (typeof date == "number" || typeof date == "string") date = new Date(date);
|
|
1297
|
+
let hours = date.getHours(), postfix = "AM";
|
|
1298
|
+
if (hours >= 12) {
|
|
1299
|
+
if (hours > 12) hours -= 12;
|
|
1300
|
+
postfix = "PM";
|
|
1301
|
+
} else if (hours == 0) hours = 12;
|
|
1302
|
+
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}, ${hours}:${date.getMinutes().toString().padStart(2, "0")} ${postfix}`;
|
|
1085
1303
|
}
|
|
1086
|
-
function
|
|
1087
|
-
return new Promise((
|
|
1304
|
+
function sleep(ms) {
|
|
1305
|
+
return new Promise((res) => setTimeout(res, ms));
|
|
1088
1306
|
}
|
|
1089
|
-
async function
|
|
1090
|
-
|
|
1307
|
+
async function sleepWhile(fn, checkInterval = 100) {
|
|
1308
|
+
while (await fn()) await sleep(checkInterval);
|
|
1091
1309
|
}
|
|
1092
|
-
function
|
|
1093
|
-
return (
|
|
1310
|
+
function timeUntil(date) {
|
|
1311
|
+
return (date instanceof Date ? date.getTime() : date) - (/* @__PURE__ */ new Date()).getTime();
|
|
1094
1312
|
}
|
|
1095
|
-
function
|
|
1313
|
+
function tyoeKeys() {
|
|
1096
1314
|
return Object.keys({});
|
|
1097
1315
|
}
|
|
1098
1316
|
export {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1317
|
+
ASet,
|
|
1318
|
+
BadGatewayError,
|
|
1319
|
+
BadRequestError,
|
|
1320
|
+
Cache,
|
|
1321
|
+
CliBackground,
|
|
1322
|
+
CliEffects,
|
|
1323
|
+
CliForeground,
|
|
1324
|
+
CustomError,
|
|
1325
|
+
ForbiddenError,
|
|
1326
|
+
GatewayTimeoutError,
|
|
1327
|
+
Http,
|
|
1328
|
+
InternalServerError,
|
|
1329
|
+
JSONAttemptParse,
|
|
1330
|
+
JSONSanitize,
|
|
1331
|
+
LOG_LEVEL,
|
|
1332
|
+
Logger,
|
|
1333
|
+
MethodNotAllowedError,
|
|
1334
|
+
NotAcceptableError,
|
|
1335
|
+
NotFoundError,
|
|
1336
|
+
NotImplementedError,
|
|
1337
|
+
PE,
|
|
1338
|
+
PES,
|
|
1339
|
+
PathError,
|
|
1340
|
+
PathEvent,
|
|
1341
|
+
PathEventEmitter,
|
|
1342
|
+
PaymentRequiredError,
|
|
1343
|
+
PromiseProgress,
|
|
1344
|
+
ServiceUnavailableError,
|
|
1345
|
+
TypedEmitter,
|
|
1346
|
+
UnauthorizedError,
|
|
1347
|
+
addUnique,
|
|
1348
|
+
arrayDiff,
|
|
1349
|
+
caseInsensitiveSort,
|
|
1350
|
+
clean,
|
|
1351
|
+
csv,
|
|
1352
|
+
dec2Frac,
|
|
1353
|
+
deepCopy,
|
|
1354
|
+
deepMerge,
|
|
1355
|
+
dotNotation,
|
|
1356
|
+
downloadFile,
|
|
1357
|
+
downloadUrl,
|
|
1358
|
+
encodeQuery,
|
|
1359
|
+
errorFromCode,
|
|
1360
|
+
escapeRegex,
|
|
1361
|
+
fileBrowser,
|
|
1362
|
+
findByProp,
|
|
1363
|
+
flattenArr,
|
|
1364
|
+
flattenObj,
|
|
1365
|
+
formData,
|
|
1366
|
+
formatBytes,
|
|
1367
|
+
formatDate,
|
|
1368
|
+
formatPhoneNumber,
|
|
1369
|
+
fracToDec,
|
|
1370
|
+
gravatar,
|
|
1371
|
+
includes,
|
|
1372
|
+
insertAt,
|
|
1373
|
+
isEqual,
|
|
1374
|
+
jwtDecode,
|
|
1375
|
+
makeArray,
|
|
1376
|
+
makeUnique,
|
|
1377
|
+
matchAll,
|
|
1378
|
+
md5,
|
|
1379
|
+
mixin,
|
|
1380
|
+
pad,
|
|
1381
|
+
parseUrl,
|
|
1382
|
+
randomHex,
|
|
1383
|
+
randomString,
|
|
1384
|
+
randomStringBuilder,
|
|
1385
|
+
sleep,
|
|
1386
|
+
sleepWhile,
|
|
1387
|
+
sortByProp,
|
|
1388
|
+
timeUntil,
|
|
1389
|
+
timestampFilename,
|
|
1390
|
+
tyoeKeys,
|
|
1391
|
+
uploadWithProgress,
|
|
1392
|
+
validateEmail
|
|
1175
1393
|
};
|
|
1176
1394
|
//# sourceMappingURL=index.mjs.map
|