esexts 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esexts.js CHANGED
@@ -1,14 +1,14 @@
1
- function l(t, e) {
1
+ function h(t, e) {
2
2
  return Object.defineProperties(t, Object.fromEntries(Object.keys(e).map((n) => [n, { value: e[n], enumerable: !1, configurable: !0, writable: !0 }])));
3
3
  }
4
- function y() {
4
+ function d() {
5
5
  return {
6
6
  new: function(...t) {
7
7
  return new this(...t);
8
8
  }
9
9
  };
10
10
  }
11
- function d(...t) {
11
+ function b(...t) {
12
12
  const e = {};
13
13
  for (const [n, r] of t)
14
14
  e[r] = function() {
@@ -16,7 +16,7 @@ function d(...t) {
16
16
  };
17
17
  return e;
18
18
  }
19
- function a(t, e, n, ...r) {
19
+ function f(t, e, n, ...r) {
20
20
  const i = {};
21
21
  for (const [u, s] of r) {
22
22
  if (e === null && n === null) {
@@ -100,8 +100,8 @@ function M(t = { array: !1 }) {
100
100
  if (s === "[object Array]")
101
101
  return t.array ? i.concat(...u) : u;
102
102
  if (s === "[object Object]") {
103
- for (const c in u)
104
- i[c] = r(i[c], u[c]);
103
+ for (const l in u)
104
+ i[l] = r(i[l], u[l]);
105
105
  return i;
106
106
  } else
107
107
  return u;
@@ -111,31 +111,31 @@ function M(t = { array: !1 }) {
111
111
  return e;
112
112
  };
113
113
  }
114
- const D = M({ array: !1 }), F = M({ array: !0 });
115
- l(Object, {
114
+ const F = M({ array: !1 }), D = M({ array: !0 });
115
+ h(Object, {
116
116
  isObject: function(t) {
117
117
  return Object.prototype.toString.call(t) === "[object Object]";
118
118
  },
119
119
  merge0: function(...t) {
120
- return D(this, ...t);
120
+ return F(this, ...t);
121
121
  },
122
122
  concat0: function(...t) {
123
- return F(this, ...t);
123
+ return D(this, ...t);
124
124
  }
125
125
  });
126
- l(Object.prototype, {
126
+ h(Object.prototype, {
127
127
  clone0: function() {
128
128
  return JSON.parse(JSON.stringify(this));
129
129
  },
130
130
  length0: function() {
131
131
  return Object.keys(this).length;
132
132
  },
133
- ...a(Object, 1, null, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
133
+ ...f(Object, 1, null, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"], ["assign", "assign0"]),
134
134
  merge0: function(...t) {
135
- return D(this, ...t);
135
+ return F(this, ...t);
136
136
  },
137
137
  concat0: function(...t) {
138
- return F(this, ...t);
138
+ return D(this, ...t);
139
139
  },
140
140
  map0: function(t = (n, r, i) => [n, r], e = 0) {
141
141
  return Object.entries(this).map(([n, r]) => t(n, r, e++));
@@ -152,13 +152,16 @@ l(Object.prototype, {
152
152
  n.has(r) || (e[r] = this[r]);
153
153
  return e;
154
154
  },
155
+ empty0: function(...t) {
156
+ return Object.keys(this).length == 0;
157
+ },
155
158
  attr0: function(t, ...e) {
156
159
  return typeof this != "object" ? this : typeof t == "function" ? t(this, ...e) : e.length > 0 ? ((e[1] === void 0 || e[1] === t in this) && (this[t] = e[0]), this) : this[t];
157
160
  },
158
161
  toArray0: function() {
159
162
  return Array.isArray(this) ? this : [this];
160
163
  },
161
- ...a(console, -1, !1, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
164
+ ...f(console, -1, !1, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
162
165
  debugger0: function(...t) {
163
166
  t.push(this), console.debug(...t);
164
167
  debugger;
@@ -175,8 +178,8 @@ l(Object.prototype, {
175
178
  getChildrens0: function(t = !1, e = -1, n = "children") {
176
179
  const r = [], i = (u, s, o) => {
177
180
  if (s && r.push(u), !(o == 0 || !u[n] || u[n].length == 0))
178
- for (const c of u[n])
179
- i(c, !0, o - 1);
181
+ for (const l of u[n])
182
+ i(l, !0, o - 1);
180
183
  };
181
184
  return i(this, t, e), r;
182
185
  },
@@ -208,31 +211,62 @@ l(Object.prototype, {
208
211
  return u[r] = s, u;
209
212
  }
210
213
  });
211
- l(Number.prototype, {
212
- ...a(Math, 1, null, ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
214
+ h(Number.prototype, {
215
+ ...f(Math, 1, null, ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
216
+ round: function(t = 0) {
217
+ return Math.round(this * 10 ** t) / 10 ** t;
218
+ },
219
+ add: function(t, ...e) {
220
+ return typeof t == "function" ? t(this, ...e) : this + t;
221
+ },
222
+ sub: function(t, ...e) {
223
+ return typeof t == "function" ? t(this, ...e) : this - t;
224
+ },
225
+ mul: function(t, ...e) {
226
+ return typeof t == "function" ? t(this, ...e) : this * t;
227
+ },
228
+ div: function(t, ...e) {
229
+ return typeof t == "function" ? t(this, ...e) : this / t;
230
+ },
213
231
  baseConvert: function(t = 64) {
214
232
  let e = "", n = this, r = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
215
233
  for (; n > 0; )
216
234
  e = r.at(n % t) + e, n = Math.floor(n / t);
217
235
  return e || "0";
218
236
  },
219
- round: function(t = 0) {
220
- return t == 0 ? Math.round(this) : Math.round(this * 10 ** t) / 10 ** t;
237
+ unit: function(t, e = 0) {
238
+ let n = this, r = "";
239
+ for ([unit, size] of Object.entries(t)) {
240
+ if (r = unit, size === 0 || n < size)
241
+ break;
242
+ n = n / size;
243
+ }
244
+ return e < 0 ? +n.toFixed(0 - e) + r : n.toFixed(e) + r;
245
+ },
246
+ units: function(t, e = !1) {
247
+ let n = this, r = [];
248
+ for ([unit, size] of Object.entries(t))
249
+ if (size == 0 || n < size) {
250
+ r.push([n, unit]);
251
+ break;
252
+ } else
253
+ r.push([n % size, unit]), n = Math.floor(n / size);
254
+ return e ? r : r.reverse().map(([i, u]) => i + u).join("");
221
255
  },
222
- toFixed0: function(...t) {
223
- return +this.toFixed(...t);
256
+ toFixed0: function(t = 0) {
257
+ return +this.toFixed(t);
224
258
  },
225
259
  toDate: function() {
226
260
  return Date.new(this);
227
261
  }
228
262
  });
229
- l(BigInt.prototype, {
263
+ h(BigInt.prototype, {
230
264
  toJSON: function() {
231
265
  return this < BigInt(Number.MIN_SAFE_INTEGER) || this > BigInt(Number.MAX_SAFE_INTEGER) ? this.toString() : Number(this);
232
266
  }
233
267
  });
234
- l(String.prototype, {
235
- ...d(["length", "length0"]),
268
+ h(String.prototype, {
269
+ ...b(["length", "length0"]),
236
270
  substring0: function(t = 0, e = this.length) {
237
271
  return t = t >= 0 ? t : this.length + t, e = e >= 0 ? e : this.length + e, this.substring(t, e);
238
272
  },
@@ -310,15 +344,15 @@ l(String.prototype, {
310
344
  return Uint8Array.fromBase64(this);
311
345
  }
312
346
  });
313
- l(Array, {
314
- ...y()
347
+ h(Array, {
348
+ ...d()
315
349
  });
316
- l(Array.prototype, {
317
- ...d(["length", "length0"]),
350
+ h(Array.prototype, {
351
+ ...b(["length", "length0"]),
318
352
  ...m(Array.prototype, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
319
- ...a(Array.prototype, null, !1, ["push", "push0"], ["pop", "pop0"], ["shift", "shift0"], ["unshift", "unshift0"]),
320
- ...a(Array.prototype, null, 1, ["push", "push1"], ["unshift", "unshift1"]),
321
- ...a(Array.prototype, null, !0, ["push", "push3"], ["unshift", "unshift3"]),
353
+ ...f(Array.prototype, null, !1, ["push", "push0"], ["pop", "pop0"], ["shift", "shift0"], ["unshift", "unshift0"]),
354
+ ...f(Array.prototype, null, 1, ["push", "push1"], ["unshift", "unshift1"]),
355
+ ...f(Array.prototype, null, !0, ["push", "push3"], ["unshift", "unshift3"]),
322
356
  first0: function(t = null) {
323
357
  return this.length ? this[0] : t;
324
358
  },
@@ -335,7 +369,7 @@ l(Array.prototype, {
335
369
  const e = /* @__PURE__ */ new Set();
336
370
  return this.filter((n) => e.has(t(n)) ? !1 : !!e.add(t(n)));
337
371
  },
338
- ...a(Array.prototype, null, !1, ["forEach", "each0"]),
372
+ ...f(Array.prototype, null, !1, ["forEach", "each0"]),
339
373
  eachAsync: async function(t) {
340
374
  for (let e = 0; e < this.length; e++)
341
375
  await t(this[e], e, this);
@@ -365,6 +399,28 @@ l(Array.prototype, {
365
399
  toUint8Array: function() {
366
400
  return new Uint8Array(this);
367
401
  },
402
+ // ====== from pinojs ======
403
+ range: function(...t) {
404
+ let e = [], n = 0, r = 0, i = 1, u = typeof t[t.length - 1] == "boolean" ? t.pop() : !0, s = typeof t[t.length - 1] == "function" ? t.pop() : (o, l, g) => o;
405
+ switch (t.length) {
406
+ case 1:
407
+ [r] = t;
408
+ break;
409
+ case 2:
410
+ [n, r] = t;
411
+ break;
412
+ case 3:
413
+ [n, r, i] = t;
414
+ break;
415
+ default:
416
+ throw new Error("the number of parameters is incorrect!");
417
+ }
418
+ if (i == 0)
419
+ throw new Error("step cannot be 0!");
420
+ for (let o = 0, l = 0, g = Math.abs(r - n), a = Math.abs(i), p = n <= r ? 1 : -1; l < g; l += a)
421
+ e.push(u ? s(n + l * p, o++, e) : s());
422
+ return e;
423
+ },
368
424
  // ====== Relational ======
369
425
  assoc: function(t, e, n = {}) {
370
426
  const r = this.unique0((u) => u[t]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
@@ -372,23 +428,23 @@ l(Array.prototype, {
372
428
  },
373
429
  // ====== Tree ======
374
430
  toTree: function(t = {}) {
375
- const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: u = "parent", children: s = "children", empty: o = null, hasRoot: c = !0 } = t, b = this.reduce((h, p) => h.attr0(p[e], p), {}), f = this.reduce((h, p) => (h.attr0(p[n], [], !1).attr0(p[n]).push0(p), h), {}), g = this.length && c ? this.find((h) => h[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [u]: null, [s]: f[0] };
376
- l(g, { [i]: { value: g, enumerable: !1, configurable: !0, writable: !0 } });
377
- for (const h of this)
378
- l(h, {
379
- [i]: { value: g, enumerable: !1, configurable: !0, writable: !0 },
380
- [u]: { value: b[h[n]], enumerable: !1, configurable: !0, writable: !0 }
381
- }), h[s] = f[h[e]] || o;
382
- return g.treeEach0((h) => h[r] = h[u] ? h[u][r] + 1 : 0, -1, s), g;
431
+ const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: u = "parent", children: s = "children", empty: o = null, hasRoot: l = !0 } = t, g = this.reduce((c, y) => c.attr0(y[e], y), {}), a = this.reduce((c, y) => (c.attr0(y[n], [], !1).attr0(y[n]).push0(y), c), {}), p = this.length && l ? this.find((c) => c[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [u]: null, [s]: a[0] };
432
+ h(p, { [i]: { value: p, enumerable: !1, configurable: !0, writable: !0 } });
433
+ for (const c of this)
434
+ h(c, {
435
+ [i]: { value: p, enumerable: !1, configurable: !0, writable: !0 },
436
+ [u]: { value: g[c[n]], enumerable: !1, configurable: !0, writable: !0 }
437
+ }), c[s] = a[c[e]] || o;
438
+ return p.treeEach0((c) => c[r] = c[u] ? c[u][r] + 1 : 0, -1, s), p;
383
439
  },
384
440
  tree2tree: function(t = {}, e = null, n = null) {
385
- const { id: r = "id", pid: i = "pid", level: u = "level", root: s = "root", parent: o = "parent", children: c = "children", empty: b = null } = t;
386
- e = e || { [r]: 0, [i]: -1, [u]: 0, [s]: null, [o]: null, [c]: this }, n = n || e;
387
- for (const f of this)
388
- l(f, {
441
+ const { id: r = "id", pid: i = "pid", level: u = "level", root: s = "root", parent: o = "parent", children: l = "children", empty: g = null } = t;
442
+ e = e || { [r]: 0, [i]: -1, [u]: 0, [s]: null, [o]: null, [l]: this }, n = n || e;
443
+ for (const a of this)
444
+ h(a, {
389
445
  [s]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
390
446
  [o]: { value: n, enumerable: !1, configurable: !0, writable: !0 }
391
- }), f[i] = n[r], f[u] = n[u] + 1, f[c] = f[c] && f[c].length ? f[c] : b, f[c]?.tree2tree(t, e, f);
447
+ }), a[i] = n[r], a[u] = n[u] + 1, a[l] = a[l] && a[l].length ? a[l] : g, a[l]?.tree2tree(t, e, a);
392
448
  return e;
393
449
  },
394
450
  treeFind0: function(t, e = !0, n = -1, r = "children") {
@@ -408,15 +464,15 @@ l(Array.prototype, {
408
464
  return this.map((u) => u.treeMap0(t, e, n, r, i));
409
465
  }
410
466
  });
411
- l(Map, {
412
- ...y()
467
+ h(Map, {
468
+ ...d()
413
469
  });
414
- l(Map.prototype, {
415
- ...d(["size", "length0"]),
470
+ h(Map.prototype, {
471
+ ...b(["size", "length0"]),
416
472
  ...m(Map.prototype, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
417
- ...a(Map.prototype, null, !1, ["set", "set0"], ["delete", "delete0"]),
418
- ...a(Map.prototype, null, 1, ["set", "set1"], ["delete", "delete1"]),
419
- ...a(Map.prototype, null, !0, ["set", "set3"], ["delete", "delete3"]),
473
+ ...f(Map.prototype, null, !1, ["set", "set0"], ["delete", "delete0"]),
474
+ ...f(Map.prototype, null, 1, ["set", "set1"], ["delete", "delete1"]),
475
+ ...f(Map.prototype, null, !0, ["set", "set3"], ["delete", "delete3"]),
420
476
  get0: function(t, e = null) {
421
477
  return this.has(t) ? this.get(t) : e;
422
478
  },
@@ -436,15 +492,15 @@ l(Map.prototype, {
436
492
  return [...this];
437
493
  }
438
494
  });
439
- l(Set, {
440
- ...y()
495
+ h(Set, {
496
+ ...d()
441
497
  });
442
- l(Set.prototype, {
443
- ...d(["size", "length0"]),
498
+ h(Set.prototype, {
499
+ ...b(["size", "length0"]),
444
500
  ...m(Set.prototype, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
445
- ...a(Set.prototype, null, !1, ["add", "add0"], ["delete", "delete0"]),
446
- ...a(Set.prototype, null, 1, ["add", "add1"], ["delete", "delete1"]),
447
- ...a(Set.prototype, null, !0, ["add", "add3"], ["delete", "delete3"]),
501
+ ...f(Set.prototype, null, !1, ["add", "add0"], ["delete", "delete0"]),
502
+ ...f(Set.prototype, null, 1, ["add", "add1"], ["delete", "delete1"]),
503
+ ...f(Set.prototype, null, !0, ["add", "add3"], ["delete", "delete3"]),
448
504
  toArray: function() {
449
505
  return [...this];
450
506
  },
@@ -452,7 +508,7 @@ l(Set.prototype, {
452
508
  return [...this];
453
509
  }
454
510
  });
455
- l(Date, {
511
+ h(Date, {
456
512
  new: function(...t) {
457
513
  return t.length != 1 ? new Date(...t) : Number.isNaN(+t[0]) ? new Date(t[0].includes("T") ? t[0] : t[0].replace(/-/g, "/")) : new Date(t[0] > 25e8 ? t[0] : t[0] * 1e3);
458
514
  },
@@ -488,7 +544,7 @@ l(Date, {
488
544
  return [n, r];
489
545
  }
490
546
  });
491
- l(Date.prototype, {
547
+ h(Date.prototype, {
492
548
  format: function(t = "y-m-d h:i:s") {
493
549
  if (this.getTime() === 0)
494
550
  return "-";
@@ -533,15 +589,15 @@ l(Date.prototype, {
533
589
  return this.getTime();
534
590
  }
535
591
  });
536
- l(RegExp, {
537
- ...y()
592
+ h(RegExp, {
593
+ ...d()
538
594
  });
539
- l(RegExp.prototype, {
595
+ h(RegExp.prototype, {
540
596
  toJSON: function() {
541
597
  return this.toString();
542
598
  }
543
599
  });
544
- l(Promise, {
600
+ h(Promise, {
545
601
  channel: function() {
546
602
  let t = null, e = null;
547
603
  return [new this((r, i) => {
@@ -549,12 +605,12 @@ l(Promise, {
549
605
  }), t, e];
550
606
  }
551
607
  });
552
- l(Promise.prototype, {
608
+ h(Promise.prototype, {
553
609
  tryCatch: function() {
554
610
  return new Promise((t) => this.then((e) => t([e, null])).catch((e) => t([null, e])));
555
611
  }
556
612
  });
557
- l(JSON, {
613
+ h(JSON, {
558
614
  parse0: function(t, e = null) {
559
615
  try {
560
616
  if (typeof t != "string")
@@ -565,17 +621,17 @@ l(JSON, {
565
621
  }
566
622
  }
567
623
  });
568
- typeof Iterator < "u" && l(Iterator.prototype, {
624
+ typeof Iterator < "u" && h(Iterator.prototype, {
569
625
  toArray: function() {
570
626
  return Array.from(this);
571
627
  }
572
628
  });
573
- l(ArrayBuffer.prototype, {
629
+ h(ArrayBuffer.prototype, {
574
630
  toUint8Array: function() {
575
631
  return new Uint8Array(this);
576
632
  }
577
633
  });
578
- typeof Uint8Array.fromBase64 > "u" && (l(Uint8Array, {
634
+ typeof Uint8Array.fromBase64 > "u" && (h(Uint8Array, {
579
635
  fromHex: function(t) {
580
636
  const e = [];
581
637
  for (let n = 0; n < t.length; n += 2)
@@ -600,7 +656,7 @@ typeof Uint8Array.fromBase64 > "u" && (l(Uint8Array, {
600
656
  }
601
657
  return new Uint8Array(e);
602
658
  }
603
- }), l(Uint8Array.prototype, {
659
+ }), h(Uint8Array.prototype, {
604
660
  toHex: function() {
605
661
  let t = "";
606
662
  for (let e = 0; e < this.length; e++)
@@ -623,7 +679,7 @@ typeof Uint8Array.fromBase64 > "u" && (l(Uint8Array, {
623
679
  return t;
624
680
  }
625
681
  }));
626
- l(Uint8Array.prototype, {
682
+ h(Uint8Array.prototype, {
627
683
  bytes2string: function() {
628
684
  return new TextDecoder().decode(this);
629
685
  },
@@ -637,8 +693,8 @@ l(Uint8Array.prototype, {
637
693
  return new Array(...this);
638
694
  }
639
695
  });
640
- let S = 0, w = 0, A = 0;
641
- l(Math, {
696
+ let O = 0, w = 0, A = 0;
697
+ h(Math, {
642
698
  randstr: function(t = 16, e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", r = "~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/") {
643
699
  if (t < e)
644
700
  throw new Error("randstr: len < slen");
@@ -657,7 +713,7 @@ l(Math, {
657
713
  return Math.floor(Math.random() * (e - t) + t);
658
714
  },
659
715
  incrid: function() {
660
- return ++S;
716
+ return ++O;
661
717
  },
662
718
  incrstr: function() {
663
719
  return "" + Math.incrid();
@@ -1 +1 @@
1
- (function(l){typeof define=="function"&&define.amd?define(l):l()})((function(){"use strict";function l(t,e){return Object.defineProperties(t,Object.fromEntries(Object.keys(e).map(n=>[n,{value:e[n],enumerable:!1,configurable:!0,writable:!0}])))}function y(){return{new:function(...t){return new this(...t)}}}function d(...t){const e={};for(const[n,r]of t)e[r]=function(){return this[n]};return e}function a(t,e,n,...r){const i={};for(const[u,s]of r){if(e===null&&n===null){i[s]=function(...o){return t[u].apply(this,o)};continue}if(e===null&&n===!1){i[s]=function(...o){return t[u].apply(this,o),this};continue}if(e===null&&n===!0){i[s]=function(...o){return t[u].apply(this,o),o};continue}if(e===null&&n>0){i[s]=function(...o){return t[u].apply(this,o),o[n-1]};continue}if(e===null&&n<0){i[s]=function(...o){return t[u].apply(this,o),o[o.length+n+1]};continue}if(e!==null&&n===null){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o)};continue}if(e!==null&&n===!1){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),this};continue}if(e!==null&&n===!0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o};continue}if(e!==null&&n>0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o[n-1]};continue}if(e!==null&&n<0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o[o.length+n+1]};continue}throw Error("unreachable")}return i}function b(t,...e){const n={};for(const[r,i]of e)n[i]=function(...u){return[...t[r].apply(this,u)]};return n}function w(t={array:!1}){return function(e={},...n){const r=(i,u)=>{const s=Object.prototype.toString.call(i),o=Object.prototype.toString.call(u);if(s!==o)return u;if(s==="[object Array]")return t.array?i.concat(...u):u;if(s==="[object Object]"){for(const c in u)i[c]=r(i[c],u[c]);return i}else return u};for(const i of n)e=r(e,i);return e}}const A=w({array:!1}),M=w({array:!0});l(Object,{isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge0:function(...t){return A(this,...t)},concat0:function(...t){return M(this,...t)}}),l(Object.prototype,{clone0:function(){return JSON.parse(JSON.stringify(this))},length0:function(){return Object.keys(this).length},...a(Object,1,null,["entries","entries0"],["keys","keys0"],["values","values0"]),merge0:function(...t){return A(this,...t)},concat0:function(...t){return M(this,...t)},map0:function(t=(n,r,i)=>[n,r],e=0){return Object.entries(this).map(([n,r])=>t(n,r,e++))},pick0:function(...t){const e={};for(const n of t)e[n]=this[n];return e},omit0:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},attr0:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):e.length>0?((e[1]===void 0||e[1]===t in this)&&(this[t]=e[0]),this):this[t]},toArray0:function(){return Array.isArray(this)?this:[this]},...a(console,-1,!1,["debug","debug0"],["log","log0"],["info","info0"],["warn","warn0"],["error","error0"],["dir","dir0"]),debugger0:function(...t){t.push(this),console.debug(...t);debugger;return this},getParents0:function(t=!1,e=-1,n="parent"){const r=t?[this]:[];let i=this[n];for(;i&&e--!=0;)r.push(i),i=i[n];return r},getChildrens0:function(t=!1,e=-1,n="children"){const r=[],i=(u,s,o)=>{if(s&&r.push(u),!(o==0||!u[n]||u[n].length==0))for(const c of u[n])i(c,!0,o-1)};return i(this,t,e),r},treeFind0:function(t,e=!0,n=-1,r="children"){if(e&&t(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(const i of this[r]){const u=i.treeFind0(t,!0,n-1,r);if(u!==null)return u}return null},treeEach0:function(t,e=!0,n=-1,r="children"){if(e&&t(this),!(n==0||!this[r]||this[r].length==0)){for(const i of this[r])i.treeEach0(t,!0,n-1,r);return this}},treeMap0:function(t,e=!0,n=-1,r="children",i=null){const u=e?t(this):this,s=[];if(n==0||!this[r]||this[r].length==0)return u;for(const o of this[r])s.push(o.treeMap0(t,!0,n-1,r,i));return u[r]=s,u}}),l(Number.prototype,{...a(Math,1,null,["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),baseConvert:function(t=64){let e="",n=this,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=r.at(n%t)+e,n=Math.floor(n/t);return e||"0"},round:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},toFixed0:function(...t){return+this.toFixed(...t)},toDate:function(){return Date.new(this)}}),l(BigInt.prototype,{toJSON:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)}}),l(String.prototype,{...d(["length","length0"]),substring0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},substr0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},split0:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.push0(n.splice(e-1).join(t))},splitNumber:function(t=","){return this.split0(t).map(e=>+e)},splitSegment:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},sprintf:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},subOf:function(t,e,n=0,r=0){for(let s=0;s<n&&r!=-1;s++,r++)r=this.indexOf(t,r);let i=this.indexOf(t,r),u=this.indexOf(e,i);return i==-1||u==-1?"":(i+=t.length,this.substring(i,u))},lastSubOf:function(t,e,n=0,r=1/0){for(let s=0;s<n&&r!=-1;s++,r--)r=this.lastIndexOf(t,r);let i=this.lastIndexOf(t,r),u=this.indexOf(e,i);return i==-1||u==-1?"":(i+=t.length,this.substring(i,u))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,"-")},kebab2under:function(){return this.replace(/-/g,"_")},baseConvert:function(t=64){let e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let r=0;r<this.length;r++)e=e*t+n.indexOf(this.at(r));return e},toFixed0:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},string2bytes:function(){return new TextEncoder().encode(this)},hex2bytes:function(){return Uint8Array.fromHex(this)},base64decode:function(){return Uint8Array.fromBase64(this)}}),l(Array,{...y()}),l(Array.prototype,{...d(["length","length0"]),...b(Array.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...a(Array.prototype,null,!1,["push","push0"],["pop","pop0"],["shift","shift0"],["unshift","unshift0"]),...a(Array.prototype,null,1,["push","push1"],["unshift","unshift1"]),...a(Array.prototype,null,!0,["push","push3"],["unshift","unshift3"]),first0:function(t=null){return this.length?this[0]:t},last0:function(t=null){return this.length?this[this.length-1]:t},find0:function(t,e=null){return this.find(t)??e},equals0:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique0:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...a(Array.prototype,null,!1,["forEach","each0"]),eachAsync:async function(t){for(let e=0;e<this.length;e++)await t(this[e],e,this);return this},mapAsync:async function(t){const e=[];for(let n=0;n<this.length;n++)e.push(await t(this[n],n,this));return e},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},bytes2string:function(){return this.toUint8Array().bytes2string()},bytes2hex:function(){return this.toUint8Array().toHex()},base64encode:function(){return this.toUint8Array().toBase64()},toUint8Array:function(){return new Uint8Array(this)},assoc:function(t,e,n={}){const r=this.unique0(u=>u[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each0(u=>u[e]=i[u[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:u="parent",children:s="children",empty:o=null,hasRoot:c=!0}=t,m=this.reduce((h,p)=>h.attr0(p[e],p),{}),f=this.reduce((h,p)=>(h.attr0(p[n],[],!1).attr0(p[n]).push0(p),h),{}),g=this.length&&c?this.find(h=>h[n]===0):{[e]:0,[n]:-1,[i]:null,[u]:null,[s]:f[0]};l(g,{[i]:{value:g,enumerable:!1,configurable:!0,writable:!0}});for(const h of this)l(h,{[i]:{value:g,enumerable:!1,configurable:!0,writable:!0},[u]:{value:m[h[n]],enumerable:!1,configurable:!0,writable:!0}}),h[s]=f[h[e]]||o;return g.treeEach0(h=>h[r]=h[u]?h[u][r]+1:0,-1,s),g},tree2tree:function(t={},e=null,n=null){const{id:r="id",pid:i="pid",level:u="level",root:s="root",parent:o="parent",children:c="children",empty:m=null}=t;e=e||{[r]:0,[i]:-1,[u]:0,[s]:null,[o]:null,[c]:this},n=n||e;for(const f of this)l(f,{[s]:{value:e,enumerable:!1,configurable:!0,writable:!0},[o]:{value:n,enumerable:!1,configurable:!0,writable:!0}}),f[i]=n[r],f[u]=n[u]+1,f[c]=f[c]&&f[c].length?f[c]:m,f[c]?.tree2tree(t,e,f);return e},treeFind0:function(t,e=!0,n=-1,r="children"){for(const i of this){const u=i.treeFind0(t,e,n,r);if(u!==null)return u}return null},treeEach0:function(t,e=!0,n=-1,r="children"){for(const i of this)i.treeEach0(t,e,n,r);return this},treeMap0:function(t,e=!0,n=-1,r="children",i=null){return this.map(u=>u.treeMap0(t,e,n,r,i))}}),l(Map,{...y()}),l(Map.prototype,{...d(["size","length0"]),...b(Map.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...a(Map.prototype,null,!1,["set","set0"],["delete","delete0"]),...a(Map.prototype,null,1,["set","set1"],["delete","delete1"]),...a(Map.prototype,null,!0,["set","set3"],["delete","delete3"]),get0:function(t,e=null){return this.has(t)?this.get(t):e},get1:function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,e(t,...n))[1]},getAsync1:async function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,await e(t,...n))[1]},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),l(Set,{...y()}),l(Set.prototype,{...d(["size","length0"]),...b(Set.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...a(Set.prototype,null,!1,["add","add0"],["delete","delete0"]),...a(Set.prototype,null,1,["add","add1"],["delete","delete1"]),...a(Set.prototype,null,!0,["add","add3"],["delete","delete3"]),toArray:function(){return[...this]},toJSON:function(){return[...this]}}),l(Date,{new:function(...t){return t.length!=1?new Date(...t):Number.isNaN(+t[0])?new Date(t[0].includes("T")?t[0]:t[0].replace(/-/g,"/")):new Date(t[0]>25e8?t[0]:t[0]*1e3)},format:function(t="y-m-d h:i:s"){return new Date().format(t)},unix:function(){return this.now()/1e3|0},fromUnix:function(t=0){return new Date((t||0)*1e3)},expr:function(t={}){return new Date().expr(t)},toDayRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=new Date(e,n,1).getTime()/1e3|0,i=new Date(e,n+1,0,23,59,59).getTime()/1e3|0;return[r,i]},toYearRange:function(){const e=new Date().getFullYear(),n=new Date(e,1,1).getTime()/1e3|0,r=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[n,r]}}),l(Date.prototype,{format:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return t.replace(/([ymdhisle])/ig,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="l"?3:2,"0"))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:t=0,m:e=0,d:n=0,h:r=0,i=0,s:u=0}){const s=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(s.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+u)},begin:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),0,1,0,0,0].slice(t))},end:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),11,t<2?31:this.getMonthDay(),23,59,59].slice(t))},week:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},toJSON:function(){return this.getTime()}}),l(RegExp,{...y()}),l(RegExp.prototype,{toJSON:function(){return this.toString()}}),l(Promise,{channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]}}),l(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),l(JSON,{parse0:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}}}),typeof Iterator<"u"&&l(Iterator.prototype,{toArray:function(){return Array.from(this)}}),l(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),typeof Uint8Array.fromBase64>"u"&&(l(Uint8Array,{fromHex:function(t){const e=[];for(let n=0;n<t.length;n+=2)e.push(Number.parseInt(t.substring(n,n+2),16));return new Uint8Array(e)},fromBase64:function(t){const e=[],n={},r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let u=0;u<r.length;u++)n[r.charAt(u)]=u;const i=t.charAt(t.length-1)!="="?t.length:t.charAt(t.length-2)!="="?t.length-1:t.length-2;for(let u=3;u<i;u+=4){const s=(n[t.charAt(u-3)]<<18)+(n[t.charAt(u-2)]<<12)+(n[t.charAt(u-1)]<<6)+n[t.charAt(u)];e.push((s&16711680)>>16,(s&65280)>>8,s&255)}if(i%4==3){const u=(n[t.charAt(i-3)]<<18)+(n[t.charAt(i-2)]<<12)+(n[t.charAt(i-1)]<<6);e.push((u&16711680)>>16,(u&65280)>>8)}else if(i%4==2){const u=(n[t.charAt(i-2)]<<18)+(n[t.charAt(i-1)]<<12);e.push((u&16711680)>>16)}return new Uint8Array(e)}}),l(Uint8Array.prototype,{toHex:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},toBase64:function(){let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const r=(this[n-2]<<16)+(this[n-1]<<8)+this[n];t+=e.charAt((r&16515072)>>18)+e.charAt((r&258048)>>12)+e.charAt((r&4032)>>6)+e.charAt(r&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+e.charAt((n&4032)>>6)+"="}else if(this.length%3==1){const n=this[this.length-1]<<16;t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+"=="}return t}})),l(Uint8Array.prototype,{bytes2string:function(){return new TextDecoder().decode(this)},bytes2hex:function(){return this.toHex()},base64encode:function(){return this.toBase64()},toArray:function(){return new Array(...this)}});let S=0,D=0,F=0;l(Math,{randstr:function(t=16,e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const i=[];for(let u=0;u<t;u++)i.push(n.charAt(Math.random()*n.length|0));for(let u=new Set,s=0,o=0;o<e;o++){do s=Math.random()*t|0;while(u.has(s));u.set(s,!0),i[s]=r.charAt(Math.random()*r.length|0)}return i.join("")},randint:function(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t)+t)},incrid:function(){return++S},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===F?t*2048+ ++D%2048:(F=t)*2048+(D=0)%2048},uniqstr:function(){return""+Math.uniqid()},sleep:function(t){return new Promise(e=>setTimeout(e,t))},useTemplate:function(t){let e=null;const n={setup(i,{slots:u}){return e=u.default,()=>{}},name:t+"Template"},r={setup(i,{attrs:u}){return()=>e?.(u)},name:t};return{[n.name]:n,[r.name]:r}}})}));
1
+ (function(h){typeof define=="function"&&define.amd?define(h):h()})((function(){"use strict";function h(t,e){return Object.defineProperties(t,Object.fromEntries(Object.keys(e).map(n=>[n,{value:e[n],enumerable:!1,configurable:!0,writable:!0}])))}function d(){return{new:function(...t){return new this(...t)}}}function b(...t){const e={};for(const[n,r]of t)e[r]=function(){return this[n]};return e}function f(t,e,n,...r){const i={};for(const[u,s]of r){if(e===null&&n===null){i[s]=function(...o){return t[u].apply(this,o)};continue}if(e===null&&n===!1){i[s]=function(...o){return t[u].apply(this,o),this};continue}if(e===null&&n===!0){i[s]=function(...o){return t[u].apply(this,o),o};continue}if(e===null&&n>0){i[s]=function(...o){return t[u].apply(this,o),o[n-1]};continue}if(e===null&&n<0){i[s]=function(...o){return t[u].apply(this,o),o[o.length+n+1]};continue}if(e!==null&&n===null){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o)};continue}if(e!==null&&n===!1){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),this};continue}if(e!==null&&n===!0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o};continue}if(e!==null&&n>0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o[n-1]};continue}if(e!==null&&n<0){i[s]=function(...o){return o.splice(e>0?e-1:o.length+e+1,0,this),t[u].apply(this,o),o[o.length+n+1]};continue}throw Error("unreachable")}return i}function m(t,...e){const n={};for(const[r,i]of e)n[i]=function(...u){return[...t[r].apply(this,u)]};return n}function w(t={array:!1}){return function(e={},...n){const r=(i,u)=>{const s=Object.prototype.toString.call(i),o=Object.prototype.toString.call(u);if(s!==o)return u;if(s==="[object Array]")return t.array?i.concat(...u):u;if(s==="[object Object]"){for(const l in u)i[l]=r(i[l],u[l]);return i}else return u};for(const i of n)e=r(e,i);return e}}const A=w({array:!1}),M=w({array:!0});h(Object,{isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge0:function(...t){return A(this,...t)},concat0:function(...t){return M(this,...t)}}),h(Object.prototype,{clone0:function(){return JSON.parse(JSON.stringify(this))},length0:function(){return Object.keys(this).length},...f(Object,1,null,["entries","entries0"],["keys","keys0"],["values","values0"],["assign","assign0"]),merge0:function(...t){return A(this,...t)},concat0:function(...t){return M(this,...t)},map0:function(t=(n,r,i)=>[n,r],e=0){return Object.entries(this).map(([n,r])=>t(n,r,e++))},pick0:function(...t){const e={};for(const n of t)e[n]=this[n];return e},omit0:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},empty0:function(...t){return Object.keys(this).length==0},attr0:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):e.length>0?((e[1]===void 0||e[1]===t in this)&&(this[t]=e[0]),this):this[t]},toArray0:function(){return Array.isArray(this)?this:[this]},...f(console,-1,!1,["debug","debug0"],["log","log0"],["info","info0"],["warn","warn0"],["error","error0"],["dir","dir0"]),debugger0:function(...t){t.push(this),console.debug(...t);debugger;return this},getParents0:function(t=!1,e=-1,n="parent"){const r=t?[this]:[];let i=this[n];for(;i&&e--!=0;)r.push(i),i=i[n];return r},getChildrens0:function(t=!1,e=-1,n="children"){const r=[],i=(u,s,o)=>{if(s&&r.push(u),!(o==0||!u[n]||u[n].length==0))for(const l of u[n])i(l,!0,o-1)};return i(this,t,e),r},treeFind0:function(t,e=!0,n=-1,r="children"){if(e&&t(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(const i of this[r]){const u=i.treeFind0(t,!0,n-1,r);if(u!==null)return u}return null},treeEach0:function(t,e=!0,n=-1,r="children"){if(e&&t(this),!(n==0||!this[r]||this[r].length==0)){for(const i of this[r])i.treeEach0(t,!0,n-1,r);return this}},treeMap0:function(t,e=!0,n=-1,r="children",i=null){const u=e?t(this):this,s=[];if(n==0||!this[r]||this[r].length==0)return u;for(const o of this[r])s.push(o.treeMap0(t,!0,n-1,r,i));return u[r]=s,u}}),h(Number.prototype,{...f(Math,1,null,["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),round:function(t=0){return Math.round(this*10**t)/10**t},add:function(t,...e){return typeof t=="function"?t(this,...e):this+t},sub:function(t,...e){return typeof t=="function"?t(this,...e):this-t},mul:function(t,...e){return typeof t=="function"?t(this,...e):this*t},div:function(t,...e){return typeof t=="function"?t(this,...e):this/t},baseConvert:function(t=64){let e="",n=this,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=r.at(n%t)+e,n=Math.floor(n/t);return e||"0"},unit:function(t,e=0){let n=this,r="";for([unit,size]of Object.entries(t)){if(r=unit,size===0||n<size)break;n=n/size}return e<0?+n.toFixed(0-e)+r:n.toFixed(e)+r},units:function(t,e=!1){let n=this,r=[];for([unit,size]of Object.entries(t))if(size==0||n<size){r.push([n,unit]);break}else r.push([n%size,unit]),n=Math.floor(n/size);return e?r:r.reverse().map(([i,u])=>i+u).join("")},toFixed0:function(t=0){return+this.toFixed(t)},toDate:function(){return Date.new(this)}}),h(BigInt.prototype,{toJSON:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)}}),h(String.prototype,{...b(["length","length0"]),substring0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},substr0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},split0:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.push0(n.splice(e-1).join(t))},splitNumber:function(t=","){return this.split0(t).map(e=>+e)},splitSegment:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},sprintf:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},subOf:function(t,e,n=0,r=0){for(let s=0;s<n&&r!=-1;s++,r++)r=this.indexOf(t,r);let i=this.indexOf(t,r),u=this.indexOf(e,i);return i==-1||u==-1?"":(i+=t.length,this.substring(i,u))},lastSubOf:function(t,e,n=0,r=1/0){for(let s=0;s<n&&r!=-1;s++,r--)r=this.lastIndexOf(t,r);let i=this.lastIndexOf(t,r),u=this.indexOf(e,i);return i==-1||u==-1?"":(i+=t.length,this.substring(i,u))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,"-")},kebab2under:function(){return this.replace(/-/g,"_")},baseConvert:function(t=64){let e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let r=0;r<this.length;r++)e=e*t+n.indexOf(this.at(r));return e},toFixed0:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},string2bytes:function(){return new TextEncoder().encode(this)},hex2bytes:function(){return Uint8Array.fromHex(this)},base64decode:function(){return Uint8Array.fromBase64(this)}}),h(Array,{...d()}),h(Array.prototype,{...b(["length","length0"]),...m(Array.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...f(Array.prototype,null,!1,["push","push0"],["pop","pop0"],["shift","shift0"],["unshift","unshift0"]),...f(Array.prototype,null,1,["push","push1"],["unshift","unshift1"]),...f(Array.prototype,null,!0,["push","push3"],["unshift","unshift3"]),first0:function(t=null){return this.length?this[0]:t},last0:function(t=null){return this.length?this[this.length-1]:t},find0:function(t,e=null){return this.find(t)??e},equals0:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique0:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...f(Array.prototype,null,!1,["forEach","each0"]),eachAsync:async function(t){for(let e=0;e<this.length;e++)await t(this[e],e,this);return this},mapAsync:async function(t){const e=[];for(let n=0;n<this.length;n++)e.push(await t(this[n],n,this));return e},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},bytes2string:function(){return this.toUint8Array().bytes2string()},bytes2hex:function(){return this.toUint8Array().toHex()},base64encode:function(){return this.toUint8Array().toBase64()},toUint8Array:function(){return new Uint8Array(this)},range:function(...t){let e=[],n=0,r=0,i=1,u=typeof t[t.length-1]=="boolean"?t.pop():!0,s=typeof t[t.length-1]=="function"?t.pop():(o,l,g)=>o;switch(t.length){case 1:[r]=t;break;case 2:[n,r]=t;break;case 3:[n,r,i]=t;break;default:throw new Error("the number of parameters is incorrect!")}if(i==0)throw new Error("step cannot be 0!");for(let o=0,l=0,g=Math.abs(r-n),a=Math.abs(i),p=n<=r?1:-1;l<g;l+=a)e.push(u?s(n+l*p,o++,e):s());return e},assoc:function(t,e,n={}){const r=this.unique0(u=>u[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each0(u=>u[e]=i[u[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:u="parent",children:s="children",empty:o=null,hasRoot:l=!0}=t,g=this.reduce((c,y)=>c.attr0(y[e],y),{}),a=this.reduce((c,y)=>(c.attr0(y[n],[],!1).attr0(y[n]).push0(y),c),{}),p=this.length&&l?this.find(c=>c[n]===0):{[e]:0,[n]:-1,[i]:null,[u]:null,[s]:a[0]};h(p,{[i]:{value:p,enumerable:!1,configurable:!0,writable:!0}});for(const c of this)h(c,{[i]:{value:p,enumerable:!1,configurable:!0,writable:!0},[u]:{value:g[c[n]],enumerable:!1,configurable:!0,writable:!0}}),c[s]=a[c[e]]||o;return p.treeEach0(c=>c[r]=c[u]?c[u][r]+1:0,-1,s),p},tree2tree:function(t={},e=null,n=null){const{id:r="id",pid:i="pid",level:u="level",root:s="root",parent:o="parent",children:l="children",empty:g=null}=t;e=e||{[r]:0,[i]:-1,[u]:0,[s]:null,[o]:null,[l]:this},n=n||e;for(const a of this)h(a,{[s]:{value:e,enumerable:!1,configurable:!0,writable:!0},[o]:{value:n,enumerable:!1,configurable:!0,writable:!0}}),a[i]=n[r],a[u]=n[u]+1,a[l]=a[l]&&a[l].length?a[l]:g,a[l]?.tree2tree(t,e,a);return e},treeFind0:function(t,e=!0,n=-1,r="children"){for(const i of this){const u=i.treeFind0(t,e,n,r);if(u!==null)return u}return null},treeEach0:function(t,e=!0,n=-1,r="children"){for(const i of this)i.treeEach0(t,e,n,r);return this},treeMap0:function(t,e=!0,n=-1,r="children",i=null){return this.map(u=>u.treeMap0(t,e,n,r,i))}}),h(Map,{...d()}),h(Map.prototype,{...b(["size","length0"]),...m(Map.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...f(Map.prototype,null,!1,["set","set0"],["delete","delete0"]),...f(Map.prototype,null,1,["set","set1"],["delete","delete1"]),...f(Map.prototype,null,!0,["set","set3"],["delete","delete3"]),get0:function(t,e=null){return this.has(t)?this.get(t):e},get1:function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,e(t,...n))[1]},getAsync1:async function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,await e(t,...n))[1]},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),h(Set,{...d()}),h(Set.prototype,{...b(["size","length0"]),...m(Set.prototype,["entries","entries0"],["keys","keys0"],["values","values0"]),...f(Set.prototype,null,!1,["add","add0"],["delete","delete0"]),...f(Set.prototype,null,1,["add","add1"],["delete","delete1"]),...f(Set.prototype,null,!0,["add","add3"],["delete","delete3"]),toArray:function(){return[...this]},toJSON:function(){return[...this]}}),h(Date,{new:function(...t){return t.length!=1?new Date(...t):Number.isNaN(+t[0])?new Date(t[0].includes("T")?t[0]:t[0].replace(/-/g,"/")):new Date(t[0]>25e8?t[0]:t[0]*1e3)},format:function(t="y-m-d h:i:s"){return new Date().format(t)},unix:function(){return this.now()/1e3|0},fromUnix:function(t=0){return new Date((t||0)*1e3)},expr:function(t={}){return new Date().expr(t)},toDayRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=new Date(e,n,1).getTime()/1e3|0,i=new Date(e,n+1,0,23,59,59).getTime()/1e3|0;return[r,i]},toYearRange:function(){const e=new Date().getFullYear(),n=new Date(e,1,1).getTime()/1e3|0,r=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[n,r]}}),h(Date.prototype,{format:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return t.replace(/([ymdhisle])/ig,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="l"?3:2,"0"))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:t=0,m:e=0,d:n=0,h:r=0,i=0,s:u=0}){const s=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(s.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+u)},begin:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),0,1,0,0,0].slice(t))},end:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),11,t<2?31:this.getMonthDay(),23,59,59].slice(t))},week:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},toJSON:function(){return this.getTime()}}),h(RegExp,{...d()}),h(RegExp.prototype,{toJSON:function(){return this.toString()}}),h(Promise,{channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]}}),h(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),h(JSON,{parse0:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}}}),typeof Iterator<"u"&&h(Iterator.prototype,{toArray:function(){return Array.from(this)}}),h(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),typeof Uint8Array.fromBase64>"u"&&(h(Uint8Array,{fromHex:function(t){const e=[];for(let n=0;n<t.length;n+=2)e.push(Number.parseInt(t.substring(n,n+2),16));return new Uint8Array(e)},fromBase64:function(t){const e=[],n={},r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let u=0;u<r.length;u++)n[r.charAt(u)]=u;const i=t.charAt(t.length-1)!="="?t.length:t.charAt(t.length-2)!="="?t.length-1:t.length-2;for(let u=3;u<i;u+=4){const s=(n[t.charAt(u-3)]<<18)+(n[t.charAt(u-2)]<<12)+(n[t.charAt(u-1)]<<6)+n[t.charAt(u)];e.push((s&16711680)>>16,(s&65280)>>8,s&255)}if(i%4==3){const u=(n[t.charAt(i-3)]<<18)+(n[t.charAt(i-2)]<<12)+(n[t.charAt(i-1)]<<6);e.push((u&16711680)>>16,(u&65280)>>8)}else if(i%4==2){const u=(n[t.charAt(i-2)]<<18)+(n[t.charAt(i-1)]<<12);e.push((u&16711680)>>16)}return new Uint8Array(e)}}),h(Uint8Array.prototype,{toHex:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},toBase64:function(){let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const r=(this[n-2]<<16)+(this[n-1]<<8)+this[n];t+=e.charAt((r&16515072)>>18)+e.charAt((r&258048)>>12)+e.charAt((r&4032)>>6)+e.charAt(r&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+e.charAt((n&4032)>>6)+"="}else if(this.length%3==1){const n=this[this.length-1]<<16;t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+"=="}return t}})),h(Uint8Array.prototype,{bytes2string:function(){return new TextDecoder().decode(this)},bytes2hex:function(){return this.toHex()},base64encode:function(){return this.toBase64()},toArray:function(){return new Array(...this)}});let O=0,F=0,D=0;h(Math,{randstr:function(t=16,e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const i=[];for(let u=0;u<t;u++)i.push(n.charAt(Math.random()*n.length|0));for(let u=new Set,s=0,o=0;o<e;o++){do s=Math.random()*t|0;while(u.has(s));u.set(s,!0),i[s]=r.charAt(Math.random()*r.length|0)}return i.join("")},randint:function(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t)+t)},incrid:function(){return++O},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===D?t*2048+ ++F%2048:(D=t)*2048+(F=0)%2048},uniqstr:function(){return""+Math.uniqid()},sleep:function(t){return new Promise(e=>setTimeout(e,t))},useTemplate:function(t){let e=null;const n={setup(i,{slots:u}){return e=u.default,()=>{}},name:t+"Template"},r={setup(i,{attrs:u}){return()=>e?.(u)},name:t};return{[n.name]:n,[r.name]:r}}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esexts",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "esexts",
5
5
  "author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
6
6
  "homepage": "https://github.com/dotcoo/esexts#readme",