esexts 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +2 -0
- package/dist/esexts.js +1228 -0
- package/dist/esexts.umd.cjs +1 -0
- package/package.json +34 -0
package/dist/esexts.js
ADDED
|
@@ -0,0 +1,1228 @@
|
|
|
1
|
+
function g(e = { array: !1 }) {
|
|
2
|
+
return function(t = {}, ...r) {
|
|
3
|
+
const u = (n, l) => {
|
|
4
|
+
const a = Object.prototype.toString.call(n), s = Object.prototype.toString.call(l);
|
|
5
|
+
if (a !== s)
|
|
6
|
+
return l;
|
|
7
|
+
if (a === "[object Array]")
|
|
8
|
+
return e.array ? n.concat(...l) : l;
|
|
9
|
+
if (a === "[object Object]") {
|
|
10
|
+
for (const f in l)
|
|
11
|
+
n[f] = u(n[f], l[f]);
|
|
12
|
+
return n;
|
|
13
|
+
} else
|
|
14
|
+
return l;
|
|
15
|
+
};
|
|
16
|
+
for (const n of r)
|
|
17
|
+
t = u(t, n);
|
|
18
|
+
return t;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const m = g({ array: !1 }), w = g({ array: !0 });
|
|
22
|
+
Object.defineProperties(Object, {
|
|
23
|
+
isObject: {
|
|
24
|
+
value: function(e) {
|
|
25
|
+
return Object.prototype.toString.call(e) === "[object Object]";
|
|
26
|
+
},
|
|
27
|
+
enumerable: !1,
|
|
28
|
+
configurable: !0,
|
|
29
|
+
writable: !0
|
|
30
|
+
},
|
|
31
|
+
merge0: {
|
|
32
|
+
value: function(...e) {
|
|
33
|
+
return m(this, ...e);
|
|
34
|
+
},
|
|
35
|
+
enumerable: !1,
|
|
36
|
+
configurable: !0,
|
|
37
|
+
writable: !0
|
|
38
|
+
},
|
|
39
|
+
concat0: {
|
|
40
|
+
value: function(...e) {
|
|
41
|
+
return w(this, ...e);
|
|
42
|
+
},
|
|
43
|
+
enumerable: !1,
|
|
44
|
+
configurable: !0,
|
|
45
|
+
writable: !0
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperties(Object.prototype, {
|
|
49
|
+
clone0: {
|
|
50
|
+
value: function() {
|
|
51
|
+
return typeof structuredClone != "structuredClone" ? structuredClone(this) : JSON.parse(JSON.stringify(this));
|
|
52
|
+
},
|
|
53
|
+
enumerable: !1,
|
|
54
|
+
configurable: !0,
|
|
55
|
+
writable: !0
|
|
56
|
+
},
|
|
57
|
+
length0: {
|
|
58
|
+
value: function() {
|
|
59
|
+
return Object.keys(this).length;
|
|
60
|
+
},
|
|
61
|
+
enumerable: !1,
|
|
62
|
+
configurable: !0,
|
|
63
|
+
writable: !0
|
|
64
|
+
},
|
|
65
|
+
entries0: {
|
|
66
|
+
value: function() {
|
|
67
|
+
return Object.entries(this);
|
|
68
|
+
},
|
|
69
|
+
enumerable: !1,
|
|
70
|
+
configurable: !0,
|
|
71
|
+
writable: !0
|
|
72
|
+
},
|
|
73
|
+
keys0: {
|
|
74
|
+
value: function() {
|
|
75
|
+
return Object.keys(this);
|
|
76
|
+
},
|
|
77
|
+
enumerable: !1,
|
|
78
|
+
configurable: !0,
|
|
79
|
+
writable: !0
|
|
80
|
+
},
|
|
81
|
+
values0: {
|
|
82
|
+
value: function() {
|
|
83
|
+
return Object.values(this);
|
|
84
|
+
},
|
|
85
|
+
enumerable: !1,
|
|
86
|
+
configurable: !0,
|
|
87
|
+
writable: !0
|
|
88
|
+
},
|
|
89
|
+
merge0: {
|
|
90
|
+
value: function(...e) {
|
|
91
|
+
return m(this, ...e);
|
|
92
|
+
},
|
|
93
|
+
enumerable: !1,
|
|
94
|
+
configurable: !0,
|
|
95
|
+
writable: !0
|
|
96
|
+
},
|
|
97
|
+
concat0: {
|
|
98
|
+
value: function(...e) {
|
|
99
|
+
return w(this, ...e);
|
|
100
|
+
},
|
|
101
|
+
enumerable: !1,
|
|
102
|
+
configurable: !0,
|
|
103
|
+
writable: !0
|
|
104
|
+
},
|
|
105
|
+
map0: {
|
|
106
|
+
value: function(e = (r, u, n) => [r, u], t = 0) {
|
|
107
|
+
return Object.entries(this).map(([r, u]) => e(r, u, t++));
|
|
108
|
+
},
|
|
109
|
+
enumerable: !1,
|
|
110
|
+
configurable: !0,
|
|
111
|
+
writable: !0
|
|
112
|
+
},
|
|
113
|
+
pick0: {
|
|
114
|
+
value: function(...e) {
|
|
115
|
+
const t = {};
|
|
116
|
+
for (const r of e)
|
|
117
|
+
t[r] = this[r];
|
|
118
|
+
return t;
|
|
119
|
+
},
|
|
120
|
+
enumerable: !1,
|
|
121
|
+
configurable: !0,
|
|
122
|
+
writable: !0
|
|
123
|
+
},
|
|
124
|
+
omit0: {
|
|
125
|
+
value: function(...e) {
|
|
126
|
+
const t = {}, r = new Set(e);
|
|
127
|
+
for (const u in this)
|
|
128
|
+
r.has(u) || (t[u] = this[u]);
|
|
129
|
+
return t;
|
|
130
|
+
},
|
|
131
|
+
enumerable: !1,
|
|
132
|
+
configurable: !0,
|
|
133
|
+
writable: !0
|
|
134
|
+
},
|
|
135
|
+
attr0: {
|
|
136
|
+
value: function(e, ...t) {
|
|
137
|
+
return typeof this != "object" ? this : typeof e == "function" ? e(this, ...t) : this[e];
|
|
138
|
+
},
|
|
139
|
+
enumerable: !1,
|
|
140
|
+
configurable: !0,
|
|
141
|
+
writable: !0
|
|
142
|
+
},
|
|
143
|
+
log0: {
|
|
144
|
+
value: function(...e) {
|
|
145
|
+
return console.log(...e, this), this;
|
|
146
|
+
},
|
|
147
|
+
enumerable: !1,
|
|
148
|
+
configurable: !0,
|
|
149
|
+
writable: !0
|
|
150
|
+
},
|
|
151
|
+
debug0: {
|
|
152
|
+
value: function(...e) {
|
|
153
|
+
return console.debug(...e, this), this;
|
|
154
|
+
},
|
|
155
|
+
enumerable: !1,
|
|
156
|
+
configurable: !0,
|
|
157
|
+
writable: !0
|
|
158
|
+
},
|
|
159
|
+
// ====== Tree ======
|
|
160
|
+
getParents0: {
|
|
161
|
+
value: function(e = !1, t = -1, r = "parent") {
|
|
162
|
+
const u = e ? [this] : [];
|
|
163
|
+
for (let n = this[r], l = t; l != 0 && n; l--)
|
|
164
|
+
u.push(n), n = n[r];
|
|
165
|
+
return u;
|
|
166
|
+
},
|
|
167
|
+
enumerable: !1,
|
|
168
|
+
configurable: !0,
|
|
169
|
+
writable: !0
|
|
170
|
+
},
|
|
171
|
+
getChildrens0: {
|
|
172
|
+
value: function(e = !1, t = -1, r = "children") {
|
|
173
|
+
this[r] = this[r] || [];
|
|
174
|
+
const u = e ? [this] : [];
|
|
175
|
+
if (t == 0)
|
|
176
|
+
return u;
|
|
177
|
+
for (const n of this[r])
|
|
178
|
+
u.push(...n.getChildrens0(!0, t - 1, r));
|
|
179
|
+
return u;
|
|
180
|
+
},
|
|
181
|
+
enumerable: !1,
|
|
182
|
+
configurable: !0,
|
|
183
|
+
writable: !0
|
|
184
|
+
},
|
|
185
|
+
treeFind0: {
|
|
186
|
+
value: function(e, t = !1, r = -1, u = "children") {
|
|
187
|
+
if (t && r != 0 && e(this))
|
|
188
|
+
return this;
|
|
189
|
+
for (const n of this[u] ?? []) {
|
|
190
|
+
const l = n.treeFind0(e, !0, r - 1, u);
|
|
191
|
+
if (l)
|
|
192
|
+
return l;
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
},
|
|
196
|
+
enumerable: !1,
|
|
197
|
+
configurable: !0,
|
|
198
|
+
writable: !0
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
Object.defineProperties(Number.prototype, {
|
|
202
|
+
ceil: {
|
|
203
|
+
value: function() {
|
|
204
|
+
return Math.ceil(this);
|
|
205
|
+
},
|
|
206
|
+
enumerable: !1,
|
|
207
|
+
configurable: !0,
|
|
208
|
+
writable: !0
|
|
209
|
+
},
|
|
210
|
+
floor: {
|
|
211
|
+
value: function() {
|
|
212
|
+
return Math.floor(this);
|
|
213
|
+
},
|
|
214
|
+
enumerable: !1,
|
|
215
|
+
configurable: !0,
|
|
216
|
+
writable: !0
|
|
217
|
+
},
|
|
218
|
+
round: {
|
|
219
|
+
value: function(e = 0) {
|
|
220
|
+
return e == 0 ? Math.round(this) : Math.round(this * 10 ** e) / 10 ** e;
|
|
221
|
+
},
|
|
222
|
+
enumerable: !1,
|
|
223
|
+
configurable: !0,
|
|
224
|
+
writable: !0
|
|
225
|
+
},
|
|
226
|
+
trunc: {
|
|
227
|
+
value: function() {
|
|
228
|
+
return Math.trunc(this);
|
|
229
|
+
},
|
|
230
|
+
enumerable: !1,
|
|
231
|
+
configurable: !0,
|
|
232
|
+
writable: !0
|
|
233
|
+
},
|
|
234
|
+
abs: {
|
|
235
|
+
value: function() {
|
|
236
|
+
return Math.abs(this);
|
|
237
|
+
},
|
|
238
|
+
enumerable: !1,
|
|
239
|
+
configurable: !0,
|
|
240
|
+
writable: !0
|
|
241
|
+
},
|
|
242
|
+
max: {
|
|
243
|
+
value: function(...e) {
|
|
244
|
+
return Math.max(this, ...e);
|
|
245
|
+
},
|
|
246
|
+
enumerable: !1,
|
|
247
|
+
configurable: !0,
|
|
248
|
+
writable: !0
|
|
249
|
+
},
|
|
250
|
+
min: {
|
|
251
|
+
value: function(...e) {
|
|
252
|
+
return Math.min(this, ...e);
|
|
253
|
+
},
|
|
254
|
+
enumerable: !1,
|
|
255
|
+
configurable: !0,
|
|
256
|
+
writable: !0
|
|
257
|
+
},
|
|
258
|
+
b64: {
|
|
259
|
+
value: function() {
|
|
260
|
+
let e = "", t = this, r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
261
|
+
for (; t > 0; )
|
|
262
|
+
e = r.at(t % 64) + e, t = Math.floor(t / 64);
|
|
263
|
+
return e;
|
|
264
|
+
},
|
|
265
|
+
enumerable: !1,
|
|
266
|
+
configurable: !0,
|
|
267
|
+
writable: !0
|
|
268
|
+
},
|
|
269
|
+
toFixed0: {
|
|
270
|
+
value: function(...e) {
|
|
271
|
+
return +this.toFixed(...e);
|
|
272
|
+
},
|
|
273
|
+
enumerable: !1,
|
|
274
|
+
configurable: !0,
|
|
275
|
+
writable: !0
|
|
276
|
+
},
|
|
277
|
+
toDate: {
|
|
278
|
+
value: function() {
|
|
279
|
+
return Date.new(this);
|
|
280
|
+
},
|
|
281
|
+
enumerable: !1,
|
|
282
|
+
configurable: !0,
|
|
283
|
+
writable: !0
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
Object.defineProperties(String.prototype, {
|
|
287
|
+
length0: {
|
|
288
|
+
value: function() {
|
|
289
|
+
return this.length;
|
|
290
|
+
},
|
|
291
|
+
enumerable: !1,
|
|
292
|
+
configurable: !0,
|
|
293
|
+
writable: !0
|
|
294
|
+
},
|
|
295
|
+
substring0: {
|
|
296
|
+
value: function(e = 0, t = this.length) {
|
|
297
|
+
return e = e >= 0 ? e : this.length + e, t = t >= 0 ? t : this.length + t, this.substring(e, t);
|
|
298
|
+
},
|
|
299
|
+
enumerable: !1,
|
|
300
|
+
configurable: !0,
|
|
301
|
+
writable: !0
|
|
302
|
+
},
|
|
303
|
+
substr0: {
|
|
304
|
+
value: function(e = 0, t = this.length) {
|
|
305
|
+
return e = e >= 0 ? e : this.length + e, t = e + t, this.substring(e, t);
|
|
306
|
+
},
|
|
307
|
+
enumerable: !1,
|
|
308
|
+
configurable: !0,
|
|
309
|
+
writable: !0
|
|
310
|
+
},
|
|
311
|
+
split0: {
|
|
312
|
+
value: function(e = ",", t = -1) {
|
|
313
|
+
const r = this ? this.split(e) : [];
|
|
314
|
+
return t === -1 ? r : r.push0(r.splice(t - 1).join(e));
|
|
315
|
+
},
|
|
316
|
+
enumerable: !1,
|
|
317
|
+
configurable: !0,
|
|
318
|
+
writable: !0
|
|
319
|
+
},
|
|
320
|
+
splitNumber: {
|
|
321
|
+
value: function(e = ",") {
|
|
322
|
+
return this.split0(e).map((t) => +t);
|
|
323
|
+
},
|
|
324
|
+
enumerable: !1,
|
|
325
|
+
configurable: !0,
|
|
326
|
+
writable: !0
|
|
327
|
+
},
|
|
328
|
+
splitSegment: {
|
|
329
|
+
value: function(e = 1) {
|
|
330
|
+
const t = [];
|
|
331
|
+
for (let r = 0; r < this.length; r += e)
|
|
332
|
+
t.push(this.substring(r, e));
|
|
333
|
+
return t;
|
|
334
|
+
},
|
|
335
|
+
enumerable: !1,
|
|
336
|
+
configurable: !0,
|
|
337
|
+
writable: !0
|
|
338
|
+
},
|
|
339
|
+
sprintf: {
|
|
340
|
+
value: function(...e) {
|
|
341
|
+
let [t, ...r] = this.split(/%[sd]/);
|
|
342
|
+
for (let u = 0; u < r.length; u++)
|
|
343
|
+
t += e[u] + r[u];
|
|
344
|
+
return t;
|
|
345
|
+
},
|
|
346
|
+
enumerable: !1,
|
|
347
|
+
configurable: !0,
|
|
348
|
+
writable: !0
|
|
349
|
+
},
|
|
350
|
+
subOf: {
|
|
351
|
+
value: function(e, t, r = 0, u = 0) {
|
|
352
|
+
for (let a = 0; a < r && u != -1; a++, u++)
|
|
353
|
+
u = this.indexOf(e, u);
|
|
354
|
+
let n = this.indexOf(e, u), l = this.indexOf(t, n);
|
|
355
|
+
return n == -1 || l == -1 ? "" : (n += e.length, this.substring(n, l));
|
|
356
|
+
},
|
|
357
|
+
enumerable: !1,
|
|
358
|
+
configurable: !0,
|
|
359
|
+
writable: !0
|
|
360
|
+
},
|
|
361
|
+
lastSubOf: {
|
|
362
|
+
value: function(e, t, r = 0, u = 1 / 0) {
|
|
363
|
+
for (let a = 0; a < r && u != -1; a++, u--)
|
|
364
|
+
u = this.lastIndexOf(e, u);
|
|
365
|
+
let n = this.lastIndexOf(e, u), l = this.indexOf(t, n);
|
|
366
|
+
return n == -1 || l == -1 ? "" : (n += e.length, this.substring(n, l));
|
|
367
|
+
},
|
|
368
|
+
enumerable: !1,
|
|
369
|
+
configurable: !0,
|
|
370
|
+
writable: !0
|
|
371
|
+
},
|
|
372
|
+
camel2under: {
|
|
373
|
+
value: function() {
|
|
374
|
+
return this.substr(0, 1).toLowerCase() + this.substr(1).replace(/([A-Z])/g, (e, t) => "_" + t.toLowerCase());
|
|
375
|
+
},
|
|
376
|
+
enumerable: !1,
|
|
377
|
+
configurable: !0,
|
|
378
|
+
writable: !0
|
|
379
|
+
},
|
|
380
|
+
under2camel: {
|
|
381
|
+
value: function() {
|
|
382
|
+
return this.replace(/_([a-z])/g, (e, t) => t.toUpperCase());
|
|
383
|
+
},
|
|
384
|
+
enumerable: !1,
|
|
385
|
+
configurable: !0,
|
|
386
|
+
writable: !0
|
|
387
|
+
},
|
|
388
|
+
camel2pascal: {
|
|
389
|
+
value: function() {
|
|
390
|
+
return this.substr(0, 1).toUpperCase() + this.substr(1);
|
|
391
|
+
},
|
|
392
|
+
enumerable: !1,
|
|
393
|
+
configurable: !0,
|
|
394
|
+
writable: !0
|
|
395
|
+
},
|
|
396
|
+
pascal2camel: {
|
|
397
|
+
value: function() {
|
|
398
|
+
return this.substr(0, 1).toLowerCase() + this.substr(1);
|
|
399
|
+
},
|
|
400
|
+
enumerable: !1,
|
|
401
|
+
configurable: !0,
|
|
402
|
+
writable: !0
|
|
403
|
+
},
|
|
404
|
+
under2kebab: {
|
|
405
|
+
value: function() {
|
|
406
|
+
return this.replace(/_/g, "-");
|
|
407
|
+
},
|
|
408
|
+
enumerable: !1,
|
|
409
|
+
configurable: !0,
|
|
410
|
+
writable: !0
|
|
411
|
+
},
|
|
412
|
+
kebab2under: {
|
|
413
|
+
value: function() {
|
|
414
|
+
return this.replace(/-/g, "_");
|
|
415
|
+
},
|
|
416
|
+
enumerable: !1,
|
|
417
|
+
configurable: !0,
|
|
418
|
+
writable: !0
|
|
419
|
+
},
|
|
420
|
+
b64: {
|
|
421
|
+
value: function() {
|
|
422
|
+
let e = 0, t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
423
|
+
for (let r = 0; r < this.length; r++)
|
|
424
|
+
e = e * 64 + t.indexOf(this.at(r));
|
|
425
|
+
return e;
|
|
426
|
+
},
|
|
427
|
+
enumerable: !1,
|
|
428
|
+
configurable: !0,
|
|
429
|
+
writable: !0
|
|
430
|
+
},
|
|
431
|
+
toFixed0: {
|
|
432
|
+
value: function(...e) {
|
|
433
|
+
return +(+this).toFixed(...e);
|
|
434
|
+
},
|
|
435
|
+
enumerable: !1,
|
|
436
|
+
configurable: !0,
|
|
437
|
+
writable: !0
|
|
438
|
+
},
|
|
439
|
+
toDate: {
|
|
440
|
+
value: function() {
|
|
441
|
+
return Date.new(this);
|
|
442
|
+
},
|
|
443
|
+
enumerable: !1,
|
|
444
|
+
configurable: !0,
|
|
445
|
+
writable: !0
|
|
446
|
+
},
|
|
447
|
+
hex2bytes: {
|
|
448
|
+
value: function() {
|
|
449
|
+
const e = [];
|
|
450
|
+
for (let t = 0; t < this.length; t += 2)
|
|
451
|
+
e.push(Number.parseInt(this.substring(t, t + 2), 16));
|
|
452
|
+
return e;
|
|
453
|
+
},
|
|
454
|
+
enumerable: !1,
|
|
455
|
+
configurable: !0,
|
|
456
|
+
writable: !0
|
|
457
|
+
},
|
|
458
|
+
string2bytes: {
|
|
459
|
+
value: function() {
|
|
460
|
+
if (typeof TextEncoder < "u")
|
|
461
|
+
return Array.from(new TextEncoder().encode(this));
|
|
462
|
+
const e = [], t = encodeURIComponent(this);
|
|
463
|
+
for (let r = 0; r < t.length; )
|
|
464
|
+
e.push(t.charAt(r) == "%" ? Number.parseInt(t.substring(r + 1, r += 3), 16) : t.charCodeAt(r++));
|
|
465
|
+
return e;
|
|
466
|
+
},
|
|
467
|
+
enumerable: !1,
|
|
468
|
+
configurable: !0,
|
|
469
|
+
writable: !0
|
|
470
|
+
},
|
|
471
|
+
base64decode: {
|
|
472
|
+
value: function(e) {
|
|
473
|
+
const t = [], r = {}, u = e === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
474
|
+
for (let l = 0; l < u.length; l++)
|
|
475
|
+
r[u.charAt(l)] = l;
|
|
476
|
+
const n = this.charAt(this.length - 1) != "=" ? this.length : this.charAt(this.length - 2) != "=" ? this.length - 1 : this.length - 2;
|
|
477
|
+
for (let l = 3; l < n; l += 4) {
|
|
478
|
+
const a = (r[this.charAt(l - 3)] << 18) + (r[this.charAt(l - 2)] << 12) + (r[this.charAt(l - 1)] << 6) + r[this.charAt(l)];
|
|
479
|
+
t.push((a & 16711680) >> 16, (a & 65280) >> 8, a & 255);
|
|
480
|
+
}
|
|
481
|
+
if (n % 4 == 3) {
|
|
482
|
+
const l = (r[this.charAt(n - 3)] << 18) + (r[this.charAt(n - 2)] << 12) + (r[this.charAt(n - 1)] << 6);
|
|
483
|
+
t.push((l & 16711680) >> 16, (l & 65280) >> 8);
|
|
484
|
+
} else if (n % 4 == 2) {
|
|
485
|
+
const l = (r[this.charAt(n - 2)] << 18) + (r[this.charAt(n - 1)] << 12);
|
|
486
|
+
t.push((l & 16711680) >> 16);
|
|
487
|
+
}
|
|
488
|
+
return t;
|
|
489
|
+
},
|
|
490
|
+
enumerable: !1,
|
|
491
|
+
configurable: !0,
|
|
492
|
+
writable: !0
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
Object.defineProperties(Iterator.prototype, {
|
|
496
|
+
toArray: {
|
|
497
|
+
value: function() {
|
|
498
|
+
return Array.from(this);
|
|
499
|
+
},
|
|
500
|
+
enumerable: !1,
|
|
501
|
+
configurable: !0,
|
|
502
|
+
writable: !0
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
Object.defineProperties(Array.prototype, {
|
|
506
|
+
length0: {
|
|
507
|
+
value: function() {
|
|
508
|
+
return this.length;
|
|
509
|
+
},
|
|
510
|
+
enumerable: !1,
|
|
511
|
+
configurable: !0,
|
|
512
|
+
writable: !0
|
|
513
|
+
},
|
|
514
|
+
entries0: {
|
|
515
|
+
value: function() {
|
|
516
|
+
return this.entries();
|
|
517
|
+
},
|
|
518
|
+
enumerable: !1,
|
|
519
|
+
configurable: !0,
|
|
520
|
+
writable: !0
|
|
521
|
+
},
|
|
522
|
+
push0: {
|
|
523
|
+
value: function(...e) {
|
|
524
|
+
return this.push(...e), this;
|
|
525
|
+
},
|
|
526
|
+
enumerable: !1,
|
|
527
|
+
configurable: !0,
|
|
528
|
+
writable: !0
|
|
529
|
+
},
|
|
530
|
+
push1: {
|
|
531
|
+
value: function(...e) {
|
|
532
|
+
return this.push(...e), e[0];
|
|
533
|
+
},
|
|
534
|
+
enumerable: !1,
|
|
535
|
+
configurable: !0,
|
|
536
|
+
writable: !0
|
|
537
|
+
},
|
|
538
|
+
push3: {
|
|
539
|
+
value: function(...e) {
|
|
540
|
+
return this.push(...e), e;
|
|
541
|
+
},
|
|
542
|
+
enumerable: !1,
|
|
543
|
+
configurable: !0,
|
|
544
|
+
writable: !0
|
|
545
|
+
},
|
|
546
|
+
pop0: {
|
|
547
|
+
value: function(...e) {
|
|
548
|
+
return this.pop(...e), this;
|
|
549
|
+
},
|
|
550
|
+
enumerable: !1,
|
|
551
|
+
configurable: !0,
|
|
552
|
+
writable: !0
|
|
553
|
+
},
|
|
554
|
+
pop1: {
|
|
555
|
+
value: function(...e) {
|
|
556
|
+
return this.pop(...e), e[0];
|
|
557
|
+
},
|
|
558
|
+
enumerable: !1,
|
|
559
|
+
configurable: !0,
|
|
560
|
+
writable: !0
|
|
561
|
+
},
|
|
562
|
+
pop3: {
|
|
563
|
+
value: function(...e) {
|
|
564
|
+
return this.pop(...e), e;
|
|
565
|
+
},
|
|
566
|
+
enumerable: !1,
|
|
567
|
+
configurable: !0,
|
|
568
|
+
writable: !0
|
|
569
|
+
},
|
|
570
|
+
unshift0: {
|
|
571
|
+
value: function(...e) {
|
|
572
|
+
return this.unshift(...e), this;
|
|
573
|
+
},
|
|
574
|
+
enumerable: !1,
|
|
575
|
+
configurable: !0,
|
|
576
|
+
writable: !0
|
|
577
|
+
},
|
|
578
|
+
unshift1: {
|
|
579
|
+
value: function(...e) {
|
|
580
|
+
return this.unshift(...e), e[0];
|
|
581
|
+
},
|
|
582
|
+
enumerable: !1,
|
|
583
|
+
configurable: !0,
|
|
584
|
+
writable: !0
|
|
585
|
+
},
|
|
586
|
+
unshift3: {
|
|
587
|
+
value: function(...e) {
|
|
588
|
+
return this.unshift(...e), e;
|
|
589
|
+
},
|
|
590
|
+
enumerable: !1,
|
|
591
|
+
configurable: !0,
|
|
592
|
+
writable: !0
|
|
593
|
+
},
|
|
594
|
+
shift0: {
|
|
595
|
+
value: function(...e) {
|
|
596
|
+
return this.shift(...e), this;
|
|
597
|
+
},
|
|
598
|
+
enumerable: !1,
|
|
599
|
+
configurable: !0,
|
|
600
|
+
writable: !0
|
|
601
|
+
},
|
|
602
|
+
shift1: {
|
|
603
|
+
value: function(...e) {
|
|
604
|
+
return this.shift(...e), e[0];
|
|
605
|
+
},
|
|
606
|
+
enumerable: !1,
|
|
607
|
+
configurable: !0,
|
|
608
|
+
writable: !0
|
|
609
|
+
},
|
|
610
|
+
shift3: {
|
|
611
|
+
value: function(...e) {
|
|
612
|
+
return this.shift(...e), e;
|
|
613
|
+
},
|
|
614
|
+
enumerable: !1,
|
|
615
|
+
configurable: !0,
|
|
616
|
+
writable: !0
|
|
617
|
+
},
|
|
618
|
+
first0: {
|
|
619
|
+
value: function(e = null) {
|
|
620
|
+
return this.length ? this[0] : e;
|
|
621
|
+
},
|
|
622
|
+
enumerable: !1,
|
|
623
|
+
configurable: !0,
|
|
624
|
+
writable: !0
|
|
625
|
+
},
|
|
626
|
+
last0: {
|
|
627
|
+
value: function(e = null) {
|
|
628
|
+
return this.length ? this[this.length - 1] : e;
|
|
629
|
+
},
|
|
630
|
+
enumerable: !1,
|
|
631
|
+
configurable: !0,
|
|
632
|
+
writable: !0
|
|
633
|
+
},
|
|
634
|
+
find0: {
|
|
635
|
+
value: function(e, t = null) {
|
|
636
|
+
return this.find(e) ?? t;
|
|
637
|
+
},
|
|
638
|
+
enumerable: !1,
|
|
639
|
+
configurable: !0,
|
|
640
|
+
writable: !0
|
|
641
|
+
},
|
|
642
|
+
equals0: {
|
|
643
|
+
value: function(e) {
|
|
644
|
+
return this.length === e.length && (this === e || this.length === 0 || this.every((t, r) => t === e[r]));
|
|
645
|
+
},
|
|
646
|
+
enumerable: !1,
|
|
647
|
+
configurable: !0,
|
|
648
|
+
writable: !0
|
|
649
|
+
},
|
|
650
|
+
unique0: {
|
|
651
|
+
value: function(e = (t) => t) {
|
|
652
|
+
const t = /* @__PURE__ */ new Set();
|
|
653
|
+
return this.filter((r) => t.has(e(r)) ? !1 : !!t.add(e(r)));
|
|
654
|
+
},
|
|
655
|
+
enumerable: !1,
|
|
656
|
+
configurable: !0,
|
|
657
|
+
writable: !0
|
|
658
|
+
},
|
|
659
|
+
each0: {
|
|
660
|
+
value: function(e) {
|
|
661
|
+
return this.forEach(e), this;
|
|
662
|
+
},
|
|
663
|
+
enumerable: !1,
|
|
664
|
+
configurable: !0,
|
|
665
|
+
writable: !0
|
|
666
|
+
},
|
|
667
|
+
toObject: {
|
|
668
|
+
value: function(e = (t, r) => [r, t]) {
|
|
669
|
+
return Object.fromEntries(this.map(e));
|
|
670
|
+
},
|
|
671
|
+
enumerable: !1,
|
|
672
|
+
configurable: !0,
|
|
673
|
+
writable: !0
|
|
674
|
+
},
|
|
675
|
+
toMap: {
|
|
676
|
+
value: function(e = (t, r) => [r, t]) {
|
|
677
|
+
return new Map(this.map(e));
|
|
678
|
+
},
|
|
679
|
+
enumerable: !1,
|
|
680
|
+
configurable: !0,
|
|
681
|
+
writable: !0
|
|
682
|
+
},
|
|
683
|
+
toSet: {
|
|
684
|
+
value: function() {
|
|
685
|
+
return new Set(this);
|
|
686
|
+
},
|
|
687
|
+
enumerable: !1,
|
|
688
|
+
configurable: !0,
|
|
689
|
+
writable: !0
|
|
690
|
+
},
|
|
691
|
+
toGroup: {
|
|
692
|
+
value: function(e = (t) => [t.id, t]) {
|
|
693
|
+
const t = {};
|
|
694
|
+
for (const r of this) {
|
|
695
|
+
const [u, n] = e(r);
|
|
696
|
+
u in t || (t[u] = []), t[u].push(n);
|
|
697
|
+
}
|
|
698
|
+
return t;
|
|
699
|
+
},
|
|
700
|
+
enumerable: !1,
|
|
701
|
+
configurable: !0,
|
|
702
|
+
writable: !0
|
|
703
|
+
},
|
|
704
|
+
toMerge: {
|
|
705
|
+
value: function(e = (u) => u.id, t = (u) => ({ ...u, children: u.children || [] }), r = (u, n) => u.children.push(n)) {
|
|
706
|
+
const u = [];
|
|
707
|
+
for (const n of this)
|
|
708
|
+
r(u.find((l) => e(l) == e(n)) ?? u.push1(t(n)), n);
|
|
709
|
+
return u;
|
|
710
|
+
},
|
|
711
|
+
enumerable: !1,
|
|
712
|
+
configurable: !0,
|
|
713
|
+
writable: !0
|
|
714
|
+
},
|
|
715
|
+
bytes2hex: {
|
|
716
|
+
value: function() {
|
|
717
|
+
let e = "";
|
|
718
|
+
for (let t = 0; t < this.length; t++)
|
|
719
|
+
e += (this[t] < 16 ? "0" : "") + this[t].toString(16);
|
|
720
|
+
return e;
|
|
721
|
+
},
|
|
722
|
+
enumerable: !1,
|
|
723
|
+
configurable: !0,
|
|
724
|
+
writable: !0
|
|
725
|
+
},
|
|
726
|
+
bytes2string: {
|
|
727
|
+
value: function() {
|
|
728
|
+
if (typeof TextDecoder < "u")
|
|
729
|
+
return new TextDecoder().decode(new Uint8Array(this));
|
|
730
|
+
let e = "";
|
|
731
|
+
for (let t = 0; t < this.length; t++)
|
|
732
|
+
e += "%" + (this[t] < 16 ? "0" : "") + this[t].toString(16);
|
|
733
|
+
return decodeURIComponent(e);
|
|
734
|
+
},
|
|
735
|
+
enumerable: !1,
|
|
736
|
+
configurable: !0,
|
|
737
|
+
writable: !0
|
|
738
|
+
},
|
|
739
|
+
base64encode: {
|
|
740
|
+
value: function(e, t) {
|
|
741
|
+
let r = "", u = e === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
742
|
+
for (let n = 2; n < this.length; n += 3) {
|
|
743
|
+
const l = (this[n - 2] << 16) + (this[n - 1] << 8) + this[n];
|
|
744
|
+
r += u.charAt((l & 16515072) >> 18) + u.charAt((l & 258048) >> 12) + u.charAt((l & 4032) >> 6) + u.charAt(l & 63);
|
|
745
|
+
}
|
|
746
|
+
if (this.length % 3 == 2) {
|
|
747
|
+
const n = (this[this.length - 2] << 16) + (this[this.length - 1] << 8);
|
|
748
|
+
r += u.charAt((n & 16515072) >> 18) + u.charAt((n & 258048) >> 12) + u.charAt((n & 4032) >> 6) + (t === !1 ? "" : "=");
|
|
749
|
+
} else if (this.length % 3 == 1) {
|
|
750
|
+
const n = this[this.length - 1] << 16;
|
|
751
|
+
r += u.charAt((n & 16515072) >> 18) + u.charAt((n & 258048) >> 12) + (t === !1 ? "" : "==");
|
|
752
|
+
}
|
|
753
|
+
return r;
|
|
754
|
+
},
|
|
755
|
+
enumerable: !1,
|
|
756
|
+
configurable: !0,
|
|
757
|
+
writable: !0
|
|
758
|
+
},
|
|
759
|
+
toUint8Array: {
|
|
760
|
+
value: function() {
|
|
761
|
+
return new Uint8Array(this);
|
|
762
|
+
},
|
|
763
|
+
enumerable: !1,
|
|
764
|
+
configurable: !0,
|
|
765
|
+
writable: !0
|
|
766
|
+
},
|
|
767
|
+
// ====== Relational ======
|
|
768
|
+
assoc: {
|
|
769
|
+
value: function(e, t, r = {}) {
|
|
770
|
+
const u = this.unique0((l) => l[e]), n = u.length == 0 ? {} : typeof r == "function" ? r(u) : r;
|
|
771
|
+
return this.each0((l) => l[t] = n[l[e]] ?? null);
|
|
772
|
+
},
|
|
773
|
+
enumerable: !1,
|
|
774
|
+
configurable: !0,
|
|
775
|
+
writable: !0
|
|
776
|
+
},
|
|
777
|
+
// ====== Tree ======
|
|
778
|
+
toTreeRecursion: {
|
|
779
|
+
value: function(e = null, t = null, r = {}) {
|
|
780
|
+
const u = [], { id: n = "id", pid: l = "pid", level: a = "level", parent: s = "parent", children: f = "children", root: b = "root", empty: c = null } = r;
|
|
781
|
+
for (const o of this)
|
|
782
|
+
o[l] === ((t == null ? void 0 : t[n]) ?? 0) && (Object.defineProperties(o, {
|
|
783
|
+
[b]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
|
|
784
|
+
[s]: { value: t, enumerable: !1, configurable: !0, writable: !0 }
|
|
785
|
+
}), o[a] = ((t == null ? void 0 : t[a]) ?? -1) + 1, o[f] = this.toTreeRecursion(e, o, r), u.push(o));
|
|
786
|
+
return u.length ? u : c;
|
|
787
|
+
},
|
|
788
|
+
enumerable: !1,
|
|
789
|
+
configurable: !0,
|
|
790
|
+
writable: !0
|
|
791
|
+
},
|
|
792
|
+
toTree: {
|
|
793
|
+
value: function(e = null, t = null, r = {}) {
|
|
794
|
+
const u = [], { id: n = "id", pid: l = "pid", level: a = "level", parent: s = "parent", children: f = "children", root: b = "root", empty: c = null } = r, o = this.toObject((i) => [i[n], i]), p = this.toGroup((i) => [i[l], i]);
|
|
795
|
+
for (const i of this)
|
|
796
|
+
Object.defineProperties(i, {
|
|
797
|
+
[b]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
|
|
798
|
+
[s]: { value: o[i[l]] ?? t, enumerable: !1, configurable: !0, writable: !0 }
|
|
799
|
+
}), i[a] = null, i[f] = p[i[n]] ?? c, i[l] === ((e == null ? void 0 : e[n]) ?? 0) && u.push(i);
|
|
800
|
+
return u.treeEach((i) => {
|
|
801
|
+
var h;
|
|
802
|
+
return i[a] = (((h = i[s]) == null ? void 0 : h[a]) ?? -1) + 1;
|
|
803
|
+
}, { children: f, empty: c }), u;
|
|
804
|
+
},
|
|
805
|
+
enumerable: !1,
|
|
806
|
+
configurable: !0,
|
|
807
|
+
writable: !0
|
|
808
|
+
},
|
|
809
|
+
treeEach: {
|
|
810
|
+
value: function(e = (r) => r, t = {}) {
|
|
811
|
+
const { children: r = "children", empty: u = null } = t;
|
|
812
|
+
return this.each0((n, l, a) => {
|
|
813
|
+
var s;
|
|
814
|
+
n[r] = n[r] || u, e(n, l, a), (s = n[r]) == null || s.treeEach(e, t);
|
|
815
|
+
});
|
|
816
|
+
},
|
|
817
|
+
enumerable: !1,
|
|
818
|
+
configurable: !0,
|
|
819
|
+
writable: !0
|
|
820
|
+
},
|
|
821
|
+
treeMap: {
|
|
822
|
+
value: function(e = (r) => r, t = {}) {
|
|
823
|
+
const { children: r = "children", empty: u = null } = t;
|
|
824
|
+
return this.map((n, l, a) => {
|
|
825
|
+
var s;
|
|
826
|
+
return n[r] = n[r] || u, n = e(n, l, a), n[r] = ((s = n[r]) == null ? void 0 : s.treeMap(e, t)) ?? u, n;
|
|
827
|
+
});
|
|
828
|
+
},
|
|
829
|
+
enumerable: !1,
|
|
830
|
+
configurable: !0,
|
|
831
|
+
writable: !0
|
|
832
|
+
},
|
|
833
|
+
tree2tree: {
|
|
834
|
+
value: function(e = null, t = null, r = {}) {
|
|
835
|
+
var c;
|
|
836
|
+
const { id: u = "id", pid: n = "pid", level: l = "level", parent: a = "parent", children: s = "children", root: f = "root", empty: b = null } = r;
|
|
837
|
+
for (const o of this)
|
|
838
|
+
Object.defineProperties(o, {
|
|
839
|
+
[f]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
|
|
840
|
+
[a]: { value: t, enumerable: !1, configurable: !0, writable: !0 }
|
|
841
|
+
}), o[n] = (t == null ? void 0 : t[u]) ?? null, o[l] = ((t == null ? void 0 : t[l]) ?? -1) + 1, o[s] = ((c = o[s]) == null ? void 0 : c.tree2tree(e, o, r)) ?? b;
|
|
842
|
+
return this;
|
|
843
|
+
},
|
|
844
|
+
enumerable: !1,
|
|
845
|
+
configurable: !0,
|
|
846
|
+
writable: !0
|
|
847
|
+
},
|
|
848
|
+
treeFind0: {
|
|
849
|
+
value: function(e, t = "children") {
|
|
850
|
+
var r;
|
|
851
|
+
for (const u of this) {
|
|
852
|
+
if (e(u))
|
|
853
|
+
return u;
|
|
854
|
+
const n = (r = u[t]) == null ? void 0 : r.treeFind0(e, t);
|
|
855
|
+
if (n)
|
|
856
|
+
return n;
|
|
857
|
+
}
|
|
858
|
+
return null;
|
|
859
|
+
},
|
|
860
|
+
enumerable: !1,
|
|
861
|
+
configurable: !0,
|
|
862
|
+
writable: !0
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
Object.defineProperties(ArrayBuffer.prototype, {
|
|
866
|
+
toUint8Array: {
|
|
867
|
+
value: function() {
|
|
868
|
+
return new Uint8Array(this);
|
|
869
|
+
},
|
|
870
|
+
enumerable: !1,
|
|
871
|
+
configurable: !0,
|
|
872
|
+
writable: !0
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
Object.defineProperties(Uint8Array.prototype, {
|
|
876
|
+
bytes2hex: {
|
|
877
|
+
value: Array.prototype.bytes2hex,
|
|
878
|
+
enumerable: !1,
|
|
879
|
+
configurable: !0,
|
|
880
|
+
writable: !0
|
|
881
|
+
},
|
|
882
|
+
bytes2string: {
|
|
883
|
+
value: Array.prototype.bytes2string,
|
|
884
|
+
enumerable: !1,
|
|
885
|
+
configurable: !0,
|
|
886
|
+
writable: !0
|
|
887
|
+
},
|
|
888
|
+
base64encode: {
|
|
889
|
+
value: Array.prototype.base64encode,
|
|
890
|
+
enumerable: !1,
|
|
891
|
+
configurable: !0,
|
|
892
|
+
writable: !0
|
|
893
|
+
},
|
|
894
|
+
toArray: {
|
|
895
|
+
value: function() {
|
|
896
|
+
return new Array(...this);
|
|
897
|
+
},
|
|
898
|
+
enumerable: !1,
|
|
899
|
+
configurable: !0,
|
|
900
|
+
writable: !0
|
|
901
|
+
}
|
|
902
|
+
});
|
|
903
|
+
Object.defineProperties(Map.prototype, {
|
|
904
|
+
length0: {
|
|
905
|
+
value: function() {
|
|
906
|
+
return this.size;
|
|
907
|
+
},
|
|
908
|
+
enumerable: !1,
|
|
909
|
+
configurable: !0,
|
|
910
|
+
writable: !0
|
|
911
|
+
},
|
|
912
|
+
entries0: {
|
|
913
|
+
value: function() {
|
|
914
|
+
return [...this.entries()];
|
|
915
|
+
},
|
|
916
|
+
enumerable: !1,
|
|
917
|
+
configurable: !0,
|
|
918
|
+
writable: !0
|
|
919
|
+
},
|
|
920
|
+
keys0: {
|
|
921
|
+
value: function() {
|
|
922
|
+
return [...this.keys()];
|
|
923
|
+
},
|
|
924
|
+
enumerable: !1,
|
|
925
|
+
configurable: !0,
|
|
926
|
+
writable: !0
|
|
927
|
+
},
|
|
928
|
+
values0: {
|
|
929
|
+
value: function() {
|
|
930
|
+
return [...this.values()];
|
|
931
|
+
},
|
|
932
|
+
enumerable: !1,
|
|
933
|
+
configurable: !0,
|
|
934
|
+
writable: !0
|
|
935
|
+
},
|
|
936
|
+
get0: {
|
|
937
|
+
value: function(e, t = null, ...r) {
|
|
938
|
+
if (this.has(e))
|
|
939
|
+
return this.get(e);
|
|
940
|
+
const u = typeof t != "function" ? t : t(e, ...r);
|
|
941
|
+
return this.set(e, u), u;
|
|
942
|
+
},
|
|
943
|
+
enumerable: !1,
|
|
944
|
+
configurable: !0,
|
|
945
|
+
writable: !0
|
|
946
|
+
},
|
|
947
|
+
get1: {
|
|
948
|
+
value: async function(e, t = null, ...r) {
|
|
949
|
+
if (this.has(e))
|
|
950
|
+
return this.get(e);
|
|
951
|
+
const u = typeof t != "function" ? t : await t(e, ...r);
|
|
952
|
+
return this.set(e, u), u;
|
|
953
|
+
},
|
|
954
|
+
enumerable: !1,
|
|
955
|
+
configurable: !0,
|
|
956
|
+
writable: !0
|
|
957
|
+
},
|
|
958
|
+
toObject: {
|
|
959
|
+
value: function() {
|
|
960
|
+
return Object.fromEntries(this);
|
|
961
|
+
},
|
|
962
|
+
enumerable: !1,
|
|
963
|
+
configurable: !0,
|
|
964
|
+
writable: !0
|
|
965
|
+
},
|
|
966
|
+
toJSON: {
|
|
967
|
+
value: function() {
|
|
968
|
+
return [...this];
|
|
969
|
+
},
|
|
970
|
+
enumerable: !1,
|
|
971
|
+
configurable: !0,
|
|
972
|
+
writable: !0
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
Object.defineProperties(Set.prototype, {
|
|
976
|
+
length0: {
|
|
977
|
+
value: function() {
|
|
978
|
+
return this.size;
|
|
979
|
+
},
|
|
980
|
+
enumerable: !1,
|
|
981
|
+
configurable: !0,
|
|
982
|
+
writable: !0
|
|
983
|
+
},
|
|
984
|
+
entries0: {
|
|
985
|
+
value: function() {
|
|
986
|
+
return this.entries();
|
|
987
|
+
},
|
|
988
|
+
enumerable: !1,
|
|
989
|
+
configurable: !0,
|
|
990
|
+
writable: !0
|
|
991
|
+
},
|
|
992
|
+
toArray: {
|
|
993
|
+
value: function() {
|
|
994
|
+
return [...this];
|
|
995
|
+
},
|
|
996
|
+
enumerable: !1,
|
|
997
|
+
configurable: !0,
|
|
998
|
+
writable: !0
|
|
999
|
+
},
|
|
1000
|
+
toJSON: {
|
|
1001
|
+
value: function() {
|
|
1002
|
+
return [...this];
|
|
1003
|
+
},
|
|
1004
|
+
enumerable: !1,
|
|
1005
|
+
configurable: !0,
|
|
1006
|
+
writable: !0
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
Object.defineProperties(Date, {
|
|
1010
|
+
new: {
|
|
1011
|
+
value: function(...e) {
|
|
1012
|
+
return e.length != 1 ? new Date(...e) : Number.isNaN(+e[0]) ? new Date(e[0].includes("T") ? e[0] : e[0].replace(/-/g, "/")) : new Date(e[0] > 265e7 ? e[0] : e[0] * 1e3);
|
|
1013
|
+
},
|
|
1014
|
+
enumerable: !1,
|
|
1015
|
+
configurable: !0,
|
|
1016
|
+
writable: !0
|
|
1017
|
+
},
|
|
1018
|
+
format: {
|
|
1019
|
+
value: function(e = "y-m-d h:i:s") {
|
|
1020
|
+
return (/* @__PURE__ */ new Date()).format(e);
|
|
1021
|
+
},
|
|
1022
|
+
enumerable: !1,
|
|
1023
|
+
configurable: !0,
|
|
1024
|
+
writable: !0
|
|
1025
|
+
},
|
|
1026
|
+
unix: {
|
|
1027
|
+
value: function() {
|
|
1028
|
+
return this.now() / 1e3 | 0;
|
|
1029
|
+
},
|
|
1030
|
+
enumerable: !1,
|
|
1031
|
+
configurable: !0,
|
|
1032
|
+
writable: !0
|
|
1033
|
+
},
|
|
1034
|
+
fromUnix: {
|
|
1035
|
+
value: function(e = 0) {
|
|
1036
|
+
return this.new((e || 0) * 1e3);
|
|
1037
|
+
},
|
|
1038
|
+
enumerable: !1,
|
|
1039
|
+
configurable: !0,
|
|
1040
|
+
writable: !0
|
|
1041
|
+
},
|
|
1042
|
+
expr: {
|
|
1043
|
+
value: function(e = {}) {
|
|
1044
|
+
return (/* @__PURE__ */ new Date()).expr(e);
|
|
1045
|
+
},
|
|
1046
|
+
enumerable: !1,
|
|
1047
|
+
configurable: !0,
|
|
1048
|
+
writable: !0
|
|
1049
|
+
},
|
|
1050
|
+
toDayRange: {
|
|
1051
|
+
value: function() {
|
|
1052
|
+
const e = /* @__PURE__ */ new Date(), t = e.getFullYear(), r = e.getMonth(), u = e.getDate(), n = new Date(t, r, u).getTime() / 1e3 | 0;
|
|
1053
|
+
return [n, n + 86400 - 1];
|
|
1054
|
+
},
|
|
1055
|
+
enumerable: !1,
|
|
1056
|
+
configurable: !0,
|
|
1057
|
+
writable: !0
|
|
1058
|
+
},
|
|
1059
|
+
toWeekRange: {
|
|
1060
|
+
value: function() {
|
|
1061
|
+
let e = /* @__PURE__ */ new Date();
|
|
1062
|
+
for (; e.getDay() != 1; )
|
|
1063
|
+
e = new Date(e.getTime() - 86400);
|
|
1064
|
+
const t = e.getFullYear(), r = e.getMonth(), u = e.getDate(), n = new Date(t, r, u).getTime() / 1e3 | 0;
|
|
1065
|
+
return [n, n + 86400 * 7 - 1];
|
|
1066
|
+
},
|
|
1067
|
+
enumerable: !1,
|
|
1068
|
+
configurable: !0,
|
|
1069
|
+
writable: !0
|
|
1070
|
+
},
|
|
1071
|
+
toMonthRange: {
|
|
1072
|
+
value: function() {
|
|
1073
|
+
const e = /* @__PURE__ */ new Date(), t = e.getFullYear(), r = e.getMonth(), u = new Date(t, r, 1).getTime() / 1e3 | 0, n = new Date(t, r + 1, 0, 23, 59, 59).getTime() / 1e3 | 0;
|
|
1074
|
+
return [u, n];
|
|
1075
|
+
},
|
|
1076
|
+
enumerable: !1,
|
|
1077
|
+
configurable: !0,
|
|
1078
|
+
writable: !0
|
|
1079
|
+
},
|
|
1080
|
+
toYearRange: {
|
|
1081
|
+
value: function() {
|
|
1082
|
+
const t = (/* @__PURE__ */ new Date()).getFullYear(), r = new Date(t, 1, 1).getTime() / 1e3 | 0, u = new Date(t + 1, 1, 0, 23, 59, 59).getTime() / 1e3 | 0;
|
|
1083
|
+
return [r, u];
|
|
1084
|
+
},
|
|
1085
|
+
enumerable: !1,
|
|
1086
|
+
configurable: !0,
|
|
1087
|
+
writable: !0
|
|
1088
|
+
}
|
|
1089
|
+
});
|
|
1090
|
+
Object.defineProperties(Date.prototype, {
|
|
1091
|
+
format: {
|
|
1092
|
+
value: function(e = "y-m-d h:i:s") {
|
|
1093
|
+
if (this.getTime() === 0)
|
|
1094
|
+
return "-";
|
|
1095
|
+
const t = {
|
|
1096
|
+
y: this.getFullYear(),
|
|
1097
|
+
m: this.getMonth() + 1,
|
|
1098
|
+
d: this.getDate(),
|
|
1099
|
+
h: this.getHours(),
|
|
1100
|
+
i: this.getMinutes(),
|
|
1101
|
+
s: this.getSeconds(),
|
|
1102
|
+
l: this.getMilliseconds(),
|
|
1103
|
+
e: this.getMonthDay()
|
|
1104
|
+
};
|
|
1105
|
+
return e.replace(/([ymdhisle])/ig, (r, u) => u >= "A" && u <= "Z" ? t[u.toLowerCase()] : t[u].toString().padStart(u === "l" ? 3 : 2, "0"));
|
|
1106
|
+
},
|
|
1107
|
+
enumerable: !1,
|
|
1108
|
+
configurable: !0,
|
|
1109
|
+
writable: !0
|
|
1110
|
+
},
|
|
1111
|
+
unix: {
|
|
1112
|
+
value: function() {
|
|
1113
|
+
return this.getTime() / 1e3 | 0;
|
|
1114
|
+
},
|
|
1115
|
+
enumerable: !1,
|
|
1116
|
+
configurable: !0,
|
|
1117
|
+
writable: !0
|
|
1118
|
+
},
|
|
1119
|
+
isLeapYear: {
|
|
1120
|
+
value: function() {
|
|
1121
|
+
return this.getFullYear() % 4 === 0 && this.getFullYear() % 400 !== 0;
|
|
1122
|
+
},
|
|
1123
|
+
enumerable: !1,
|
|
1124
|
+
configurable: !0,
|
|
1125
|
+
writable: !0
|
|
1126
|
+
},
|
|
1127
|
+
getMonthDay: {
|
|
1128
|
+
value: function() {
|
|
1129
|
+
return [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()] || (this.isLeapYear() ? 29 : 28);
|
|
1130
|
+
},
|
|
1131
|
+
enumerable: !1,
|
|
1132
|
+
configurable: !0,
|
|
1133
|
+
writable: !0
|
|
1134
|
+
},
|
|
1135
|
+
expr: {
|
|
1136
|
+
value: function({ y: e = 0, m: t = 0, d: r = 0, h: u = 0, i: n = 0, s: l = 0 }) {
|
|
1137
|
+
const a = new Date(this.getFullYear() + e, this.getMonth() + t + 1, 0);
|
|
1138
|
+
return new Date(this.getFullYear() + e, this.getMonth() + t, Math.min(a.getDate(), this.getDate()) + r, this.getHours() + u, this.getMinutes() + n, this.getSeconds() + l);
|
|
1139
|
+
},
|
|
1140
|
+
enumerable: !1,
|
|
1141
|
+
configurable: !0,
|
|
1142
|
+
writable: !0
|
|
1143
|
+
},
|
|
1144
|
+
begin: {
|
|
1145
|
+
value: function(e = 3) {
|
|
1146
|
+
return new Date(...[this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()].slice(0, e), ...[this.getFullYear(), 0, 1, 0, 0, 0].slice(e));
|
|
1147
|
+
},
|
|
1148
|
+
enumerable: !1,
|
|
1149
|
+
configurable: !0,
|
|
1150
|
+
writable: !0
|
|
1151
|
+
},
|
|
1152
|
+
end: {
|
|
1153
|
+
value: function(e = 3) {
|
|
1154
|
+
return new Date(...[this.getFullYear(), this.getMonth(), this.getDate(), this.getHours(), this.getMinutes(), this.getSeconds()].slice(0, e), ...[this.getFullYear(), 11, e < 2 ? 31 : this.getMonthDay(), 23, 59, 59].slice(e));
|
|
1155
|
+
},
|
|
1156
|
+
enumerable: !1,
|
|
1157
|
+
configurable: !0,
|
|
1158
|
+
writable: !0
|
|
1159
|
+
},
|
|
1160
|
+
week: {
|
|
1161
|
+
value: function(e, t = 1) {
|
|
1162
|
+
let r = new Date(this.getTime());
|
|
1163
|
+
for (; r.getDay() !== e; )
|
|
1164
|
+
r = new Date(r.getTime() + 864e5 * t);
|
|
1165
|
+
return r;
|
|
1166
|
+
},
|
|
1167
|
+
enumerable: !1,
|
|
1168
|
+
configurable: !0,
|
|
1169
|
+
writable: !0
|
|
1170
|
+
},
|
|
1171
|
+
toJSON: {
|
|
1172
|
+
value: function() {
|
|
1173
|
+
return this.getTime();
|
|
1174
|
+
},
|
|
1175
|
+
enumerable: !1,
|
|
1176
|
+
configurable: !0,
|
|
1177
|
+
writable: !0
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
Object.defineProperties(RegExp.prototype, {
|
|
1181
|
+
toJSON: {
|
|
1182
|
+
value: function() {
|
|
1183
|
+
return this.toString();
|
|
1184
|
+
},
|
|
1185
|
+
enumerable: !1,
|
|
1186
|
+
configurable: !0,
|
|
1187
|
+
writable: !0
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
1190
|
+
Object.defineProperties(Promise.prototype, {
|
|
1191
|
+
tryCatch: {
|
|
1192
|
+
value: function() {
|
|
1193
|
+
return new Promise((e) => this.then((t) => e([t, null])).catch((t) => e([null, t])));
|
|
1194
|
+
},
|
|
1195
|
+
enumerable: !1,
|
|
1196
|
+
configurable: !0,
|
|
1197
|
+
writable: !0
|
|
1198
|
+
}
|
|
1199
|
+
});
|
|
1200
|
+
Object.defineProperties(Promise, {
|
|
1201
|
+
channel: {
|
|
1202
|
+
value: function() {
|
|
1203
|
+
let e = null, t = null;
|
|
1204
|
+
return [new this((u, n) => {
|
|
1205
|
+
e = u, t = n;
|
|
1206
|
+
}), e, t];
|
|
1207
|
+
},
|
|
1208
|
+
enumerable: !1,
|
|
1209
|
+
configurable: !0,
|
|
1210
|
+
writable: !0
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
Object.defineProperties(JSON, {
|
|
1214
|
+
parse0: {
|
|
1215
|
+
value: function(e, t = null) {
|
|
1216
|
+
try {
|
|
1217
|
+
if (typeof e != "string")
|
|
1218
|
+
throw new Error("not string");
|
|
1219
|
+
return JSON.parse(e);
|
|
1220
|
+
} catch {
|
|
1221
|
+
return t;
|
|
1222
|
+
}
|
|
1223
|
+
},
|
|
1224
|
+
enumerable: !1,
|
|
1225
|
+
configurable: !0,
|
|
1226
|
+
writable: !0
|
|
1227
|
+
}
|
|
1228
|
+
});
|