esexts 1.5.4 → 1.5.6

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
@@ -18,64 +18,64 @@ function b(...t) {
18
18
  }
19
19
  function a(t, e, n, ...r) {
20
20
  const i = {};
21
- for (const [u, s] of r) {
21
+ for (const [u, o] of r) {
22
22
  if (e === null && n === null) {
23
- i[s] = function(...o) {
24
- return t[u].apply(this, o);
23
+ i[o] = function(...s) {
24
+ return t[u].apply(this, s);
25
25
  };
26
26
  continue;
27
27
  }
28
28
  if (e === null && n === !1) {
29
- i[s] = function(...o) {
30
- return t[u].apply(this, o), this;
29
+ i[o] = function(...s) {
30
+ return t[u].apply(this, s), this;
31
31
  };
32
32
  continue;
33
33
  }
34
34
  if (e === null && n === !0) {
35
- i[s] = function(...o) {
36
- return t[u].apply(this, o), o;
35
+ i[o] = function(...s) {
36
+ return t[u].apply(this, s), s;
37
37
  };
38
38
  continue;
39
39
  }
40
40
  if (e === null && n > 0) {
41
- i[s] = function(...o) {
42
- return t[u].apply(this, o), o[n - 1];
41
+ i[o] = function(...s) {
42
+ return t[u].apply(this, s), s[n - 1];
43
43
  };
44
44
  continue;
45
45
  }
46
46
  if (e === null && n < 0) {
47
- i[s] = function(...o) {
48
- return t[u].apply(this, o), o[o.length + n + 1];
47
+ i[o] = function(...s) {
48
+ return t[u].apply(this, s), s[s.length + n + 1];
49
49
  };
50
50
  continue;
51
51
  }
52
52
  if (e !== null && n === null) {
53
- i[s] = function(...o) {
54
- return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o);
53
+ i[o] = function(...s) {
54
+ return s.splice(e > 0 ? e - 1 : s.length + e + 1, 0, this), t[u].apply(this, s);
55
55
  };
56
56
  continue;
57
57
  }
58
58
  if (e !== null && n === !1) {
59
- i[s] = function(...o) {
60
- return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o), this;
59
+ i[o] = function(...s) {
60
+ return s.splice(e > 0 ? e - 1 : s.length + e + 1, 0, this), t[u].apply(this, s), this;
61
61
  };
62
62
  continue;
63
63
  }
64
64
  if (e !== null && n === !0) {
65
- i[s] = function(...o) {
66
- return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o), o;
65
+ i[o] = function(...s) {
66
+ return s.splice(e > 0 ? e - 1 : s.length + e + 1, 0, this), t[u].apply(this, s), s;
67
67
  };
68
68
  continue;
69
69
  }
70
70
  if (e !== null && n > 0) {
71
- i[s] = function(...o) {
72
- return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o), o[n - 1];
71
+ i[o] = function(...s) {
72
+ return s.splice(e > 0 ? e - 1 : s.length + e + 1, 0, this), t[u].apply(this, s), s[n - 1];
73
73
  };
74
74
  continue;
75
75
  }
76
76
  if (e !== null && n < 0) {
77
- i[s] = function(...o) {
78
- return o.splice(e > 0 ? e - 1 : o.length + e + 1, 0, this), t[u].apply(this, o), o[o.length + n + 1];
77
+ i[o] = function(...s) {
78
+ return s.splice(e > 0 ? e - 1 : s.length + e + 1, 0, this), t[u].apply(this, s), s[s.length + n + 1];
79
79
  };
80
80
  continue;
81
81
  }
@@ -94,14 +94,14 @@ function m(t, ...e) {
94
94
  function M(t = { array: !1 }) {
95
95
  return function(e = {}, ...n) {
96
96
  const r = (i, u) => {
97
- const s = Object.prototype.toString.call(i), o = Object.prototype.toString.call(u);
98
- if (s !== o)
97
+ const o = Object.prototype.toString.call(i), s = Object.prototype.toString.call(u);
98
+ if (o !== s)
99
99
  return u;
100
- if (s === "[object Array]")
100
+ if (o === "[object Array]")
101
101
  return t.array ? i.concat(...u) : u;
102
- if (s === "[object Object]") {
103
- for (const c in u)
104
- i[c] = r(i[c], u[c]);
102
+ if (o === "[object Object]") {
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;
@@ -155,18 +155,24 @@ h(Object.prototype, {
155
155
  empty0: function(...t) {
156
156
  return Object.keys(this).length == 0;
157
157
  },
158
- attr0: function(t, ...e) {
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];
158
+ attr0: function(...t) {
159
+ if (typeof this != "object")
160
+ return this;
161
+ const [e, n, r, i] = t;
162
+ return t.length == 1 ? this[e] : t.length == 2 ? (this[e] = n, this) : typeof r == "boolean" ? (e in this === r && (this[e] = n), this) : r == "define" || r === null ? Object.defineProperty(this, e, { value: n, enumerable: !1, configurable: !0, writable: !0, ...i }) : r === "+" ? (this[e] = (this[e] ?? i ?? 0) + n, this) : r === "-" ? (this[e] = (this[e] ?? i ?? 0) - n, this) : r === "*" ? (this[e] = (this[e] ?? i ?? 0) * n, this) : r === "/" ? (this[e] = (this[e] ?? i ?? 0) / n, this) : this;
163
+ },
164
+ pipe0: function(t, ...e) {
165
+ return t(this, ...e);
160
166
  },
161
- call0: function(...t) {
162
- return typeof this != "function" ? this : this(...t);
167
+ handle0: function(t, ...e) {
168
+ return t(this, ...e), this;
163
169
  },
164
170
  toArray0: function() {
165
171
  return Array.isArray(this) ? this : [this];
166
172
  },
167
173
  ...a(console, -1, !1, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
168
174
  debugger0: function(...t) {
169
- t.push(this), console.debug(...t);
175
+ console.debug(this, ...t);
170
176
  debugger;
171
177
  return this;
172
178
  },
@@ -179,10 +185,10 @@ h(Object.prototype, {
179
185
  return r;
180
186
  },
181
187
  getChildrens0: function(t = !1, e = -1, n = "children") {
182
- const r = [], i = (u, s, o) => {
183
- if (s && r.push(u), !(o == 0 || !u[n] || u[n].length == 0))
184
- for (const c of u[n])
185
- i(c, !0, o - 1);
188
+ const r = [], i = (u, o, s) => {
189
+ if (o && r.push(u), !(s == 0 || !u[n] || u[n].length == 0))
190
+ for (const l of u[n])
191
+ i(l, !0, s - 1);
186
192
  };
187
193
  return i(this, t, e), r;
188
194
  },
@@ -206,12 +212,12 @@ h(Object.prototype, {
206
212
  }
207
213
  },
208
214
  treeMap0: function(t, e = !0, n = -1, r = "children", i = null) {
209
- const u = e ? t(this) : this, s = [];
215
+ const u = e ? t(this) : this, o = [];
210
216
  if (n == 0 || !this[r] || this[r].length == 0)
211
217
  return u;
212
- for (const o of this[r])
213
- s.push(o.treeMap0(t, !0, n - 1, r, i));
214
- return u[r] = s, u;
218
+ for (const s of this[r])
219
+ o.push(s.treeMap0(t, !0, n - 1, r, i));
220
+ return u[r] = o, u;
215
221
  }
216
222
  });
217
223
  h(Number.prototype, {
@@ -296,13 +302,13 @@ h(String.prototype, {
296
302
  return e;
297
303
  },
298
304
  subOf: function(t, e, n = 0, r = 0) {
299
- for (let s = 0; s < n && r != -1; s++, r++)
305
+ for (let o = 0; o < n && r != -1; o++, r++)
300
306
  r = this.indexOf(t, r);
301
307
  let i = this.indexOf(t, r), u = this.indexOf(e, i);
302
308
  return i == -1 || u == -1 ? "" : (i += t.length, this.substring(i, u));
303
309
  },
304
310
  lastSubOf: function(t, e, n = 0, r = 1 / 0) {
305
- for (let s = 0; s < n && r != -1; s++, r--)
311
+ for (let o = 0; o < n && r != -1; o++, r--)
306
312
  r = this.lastIndexOf(t, r);
307
313
  let i = this.lastIndexOf(t, r), u = this.indexOf(e, i);
308
314
  return i == -1 || u == -1 ? "" : (i += t.length, this.substring(i, u));
@@ -348,7 +354,29 @@ h(String.prototype, {
348
354
  }
349
355
  });
350
356
  h(Array, {
351
- ...d()
357
+ ...d(),
358
+ // ====== from pinojs ======
359
+ range: function(...t) {
360
+ let e = [], n = 0, r = 0, i = 1, u = typeof t[t.length - 1] == "boolean" ? t.pop() : !0, o = typeof t[t.length - 1] == "function" ? t.pop() : (s, l, g) => s;
361
+ switch (t.length) {
362
+ case 1:
363
+ [r] = t;
364
+ break;
365
+ case 2:
366
+ [n, r] = t;
367
+ break;
368
+ case 3:
369
+ [n, r, i] = t;
370
+ break;
371
+ default:
372
+ throw new Error("the number of parameters is incorrect!");
373
+ }
374
+ if (i == 0)
375
+ throw new Error("step cannot be 0!");
376
+ for (let s = 0, l = 0, g = Math.abs(r - n), f = Math.abs(i), p = n <= r ? 1 : -1; l < g; l += f)
377
+ e.push(u ? o(n + l * p, s++, e) : o());
378
+ return e;
379
+ }
352
380
  });
353
381
  h(Array.prototype, {
354
382
  ...b(["length", "length0"]),
@@ -402,28 +430,6 @@ h(Array.prototype, {
402
430
  toUint8Array: function() {
403
431
  return new Uint8Array(this);
404
432
  },
405
- // ====== from pinojs ======
406
- range: function(...t) {
407
- 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, c, g) => o;
408
- switch (t.length) {
409
- case 1:
410
- [r] = t;
411
- break;
412
- case 2:
413
- [n, r] = t;
414
- break;
415
- case 3:
416
- [n, r, i] = t;
417
- break;
418
- default:
419
- throw new Error("the number of parameters is incorrect!");
420
- }
421
- if (i == 0)
422
- throw new Error("step cannot be 0!");
423
- for (let o = 0, c = 0, g = Math.abs(r - n), f = Math.abs(i), p = n <= r ? 1 : -1; c < g; c += f)
424
- e.push(u ? s(n + c * p, o++, e) : s());
425
- return e;
426
- },
427
433
  // ====== Relational ======
428
434
  assoc: function(t, e, n = {}) {
429
435
  const r = this.unique0((u) => u[t]), i = r.length == 0 ? {} : typeof n == "function" ? n(r) : n;
@@ -431,17 +437,17 @@ h(Array.prototype, {
431
437
  },
432
438
  // ====== Tree ======
433
439
  toTree: function(t = {}) {
434
- 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, g = this.reduce((l, y) => l.attr0(y[e], y), {}), f = this.reduce((l, y) => (l.attr0(y[n], [], !1).attr0(y[n]).push0(y), l), {}), p = this.length && c ? this.find((l) => l[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [u]: null, [s]: f[0] };
440
+ const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: u = "parent", children: o = "children", empty: s = null, hasRoot: l = !0 } = t, g = this.reduce((c, y) => c.attr0(y[e], y), {}), f = 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, [o]: f[0] };
435
441
  h(p, { [i]: p });
436
- for (const l of this)
437
- h(l, { [i]: p, [u]: g[l[n]] }), l[s] = f[l[e]] || o;
438
- return p.treeEach0((l) => l[r] = l[u] ? l[u][r] + 1 : 0, -1, s), p;
442
+ for (const c of this)
443
+ h(c, { [i]: p, [u]: g[c[n]] }), c[o] = f[c[e]] || s;
444
+ return p.treeEach0((c) => c[r] = c[u] ? c[u][r] + 1 : 0, -1, o), p;
439
445
  },
440
446
  tree2tree: function(t = {}, e = null, n = null) {
441
- const { id: r = "id", pid: i = "pid", level: u = "level", root: s = "root", parent: o = "parent", children: c = "children", empty: g = null } = t;
442
- e = e || { [r]: 0, [i]: -1, [u]: 0, [s]: null, [o]: null, [c]: this }, n = n || e;
447
+ const { id: r = "id", pid: i = "pid", level: u = "level", root: o = "root", parent: s = "parent", children: l = "children", empty: g = null } = t;
448
+ e = e || { [r]: 0, [i]: -1, [u]: 0, [o]: null, [s]: null, [l]: this }, n = n || e;
443
449
  for (const f of this)
444
- h(f, { [s]: e, [o]: n }), f[i] = n[r], f[u] = n[u] + 1, f[c] = f[c] && f[c].length ? f[c] : g, f[c]?.tree2tree(t, e, f);
450
+ h(f, { [o]: e, [s]: n }), f[i] = n[r], f[u] = n[u] + 1, f[l] = f[l] && f[l].length ? f[l] : g, f[l]?.tree2tree(t, e, f);
445
451
  return e;
446
452
  },
447
453
  treeFind0: function(t, e = !0, n = -1, r = "children") {
@@ -567,8 +573,8 @@ h(Date.prototype, {
567
573
  return [31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][this.getMonth()] || (this.isLeapYear() ? 29 : 28);
568
574
  },
569
575
  expr: function({ y: t = 0, m: e = 0, d: n = 0, h: r = 0, i = 0, s: u = 0 }) {
570
- const s = new Date(this.getFullYear() + t, this.getMonth() + e + 1, 0);
571
- 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);
576
+ const o = new Date(this.getFullYear() + t, this.getMonth() + e + 1, 0);
577
+ return new Date(this.getFullYear() + t, this.getMonth() + e, Math.min(o.getDate(), this.getDate()) + n, this.getHours() + r, this.getMinutes() + i, this.getSeconds() + u);
572
578
  },
573
579
  begin: function(t = 3) {
574
580
  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));
@@ -641,8 +647,8 @@ typeof Uint8Array.fromBase64 > "u" && (h(Uint8Array, {
641
647
  n[r.charAt(u)] = u;
642
648
  const i = t.charAt(t.length - 1) != "=" ? t.length : t.charAt(t.length - 2) != "=" ? t.length - 1 : t.length - 2;
643
649
  for (let u = 3; u < i; u += 4) {
644
- const s = (n[t.charAt(u - 3)] << 18) + (n[t.charAt(u - 2)] << 12) + (n[t.charAt(u - 1)] << 6) + n[t.charAt(u)];
645
- e.push((s & 16711680) >> 16, (s & 65280) >> 8, s & 255);
650
+ const o = (n[t.charAt(u - 3)] << 18) + (n[t.charAt(u - 2)] << 12) + (n[t.charAt(u - 1)] << 6) + n[t.charAt(u)];
651
+ e.push((o & 16711680) >> 16, (o & 65280) >> 8, o & 255);
646
652
  }
647
653
  if (i % 4 == 3) {
648
654
  const u = (n[t.charAt(i - 3)] << 18) + (n[t.charAt(i - 2)] << 12) + (n[t.charAt(i - 1)] << 6);
@@ -698,11 +704,11 @@ h(Math, {
698
704
  const i = [];
699
705
  for (let u = 0; u < t; u++)
700
706
  i.push(n.charAt(Math.random() * n.length | 0));
701
- for (let u = /* @__PURE__ */ new Set(), s = 0, o = 0; o < e; o++) {
707
+ for (let u = /* @__PURE__ */ new Set(), o = 0, s = 0; s < e; s++) {
702
708
  do
703
- s = Math.random() * t | 0;
704
- while (u.has(s));
705
- u.set(s, !0), i[s] = r.charAt(Math.random() * r.length | 0);
709
+ o = Math.random() * t | 0;
710
+ while (u.has(o));
711
+ u.set(o, !0), i[o] = r.charAt(Math.random() * r.length | 0);
706
712
  }
707
713
  return i.join("");
708
714
  },
@@ -1 +1 @@
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,i]of t)e[i]=function(){return this[n]};return e}function a(t,e,n,...i){const r={};for(const[u,s]of i){if(e===null&&n===null){r[s]=function(...o){return t[u].apply(this,o)};continue}if(e===null&&n===!1){r[s]=function(...o){return t[u].apply(this,o),this};continue}if(e===null&&n===!0){r[s]=function(...o){return t[u].apply(this,o),o};continue}if(e===null&&n>0){r[s]=function(...o){return t[u].apply(this,o),o[n-1]};continue}if(e===null&&n<0){r[s]=function(...o){return t[u].apply(this,o),o[o.length+n+1]};continue}if(e!==null&&n===null){r[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){r[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){r[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){r[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){r[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 r}function m(t,...e){const n={};for(const[i,r]of e)n[r]=function(...u){return[...t[i].apply(this,u)]};return n}function w(t={array:!1}){return function(e={},...n){const i=(r,u)=>{const s=Object.prototype.toString.call(r),o=Object.prototype.toString.call(u);if(s!==o)return u;if(s==="[object Array]")return t.array?r.concat(...u):u;if(s==="[object Object]"){for(const c in u)r[c]=i(r[c],u[c]);return r}else return u};for(const r of n)e=i(e,r);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},...a(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,i,r)=>[n,i],e=0){return Object.entries(this).map(([n,i])=>t(n,i,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 i in this)n.has(i)||(e[i]=this[i]);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]},call0:function(...t){return typeof this!="function"?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 i=t?[this]:[];let r=this[n];for(;r&&e--!=0;)i.push(r),r=r[n];return i},getChildrens0:function(t=!1,e=-1,n="children"){const i=[],r=(u,s,o)=>{if(s&&i.push(u),!(o==0||!u[n]||u[n].length==0))for(const c of u[n])r(c,!0,o-1)};return r(this,t,e),i},treeFind0:function(t,e=!0,n=-1,i="children"){if(e&&t(this))return this;if(n==0||!this[i]||this[i].length==0)return null;for(const r of this[i]){const u=r.treeFind0(t,!0,n-1,i);if(u!==null)return u}return null},treeEach0:function(t,e=!0,n=-1,i="children"){if(e&&t(this),!(n==0||!this[i]||this[i].length==0)){for(const r of this[i])r.treeEach0(t,!0,n-1,i);return this}},treeMap0:function(t,e=!0,n=-1,i="children",r=null){const u=e?t(this):this,s=[];if(n==0||!this[i]||this[i].length==0)return u;for(const o of this[i])s.push(o.treeMap0(t,!0,n-1,i,r));return u[i]=s,u}}),h(Number.prototype,{...a(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,i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=i.at(n%t)+e,n=Math.floor(n/t);return e||"0"},unit:function(t,e=0){let n=this,i="";for([unit,size]of Object.entries(t)){if(i=unit,size===0||n<size)break;n=n/size}return e<0?+n.toFixed(0-e)+i:n.toFixed(e)+i},units:function(t,e=!1){let n=this,i=[];for([unit,size]of Object.entries(t))if(size==0||n<size){i.push([n,unit]);break}else i.push([n%size,unit]),n=Math.floor(n/size);return e?i:i.reverse().map(([r,u])=>r+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 i=0;i<n.length;i++)e+=t[i]+n[i];return e},subOf:function(t,e,n=0,i=0){for(let s=0;s<n&&i!=-1;s++,i++)i=this.indexOf(t,i);let r=this.indexOf(t,i),u=this.indexOf(e,r);return r==-1||u==-1?"":(r+=t.length,this.substring(r,u))},lastSubOf:function(t,e,n=0,i=1/0){for(let s=0;s<n&&i!=-1;s++,i--)i=this.lastIndexOf(t,i);let r=this.lastIndexOf(t,i),u=this.indexOf(e,r);return r==-1||u==-1?"":(r+=t.length,this.substring(r,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 i=0;i<this.length;i++)e=e*t+n.indexOf(this.at(i));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"]),...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)},range:function(...t){let e=[],n=0,i=0,r=1,u=typeof t[t.length-1]=="boolean"?t.pop():!0,s=typeof t[t.length-1]=="function"?t.pop():(o,c,g)=>o;switch(t.length){case 1:[i]=t;break;case 2:[n,i]=t;break;case 3:[n,i,r]=t;break;default:throw new Error("the number of parameters is incorrect!")}if(r==0)throw new Error("step cannot be 0!");for(let o=0,c=0,g=Math.abs(i-n),f=Math.abs(r),p=n<=i?1:-1;c<g;c+=f)e.push(u?s(n+c*p,o++,e):s());return e},assoc:function(t,e,n={}){const i=this.unique0(u=>u[t]),r=i.length==0?{}:typeof n=="function"?n(i):n;return this.each0(u=>u[e]=r[u[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:i="level",root:r="root",parent:u="parent",children:s="children",empty:o=null,hasRoot:c=!0}=t,g=this.reduce((l,y)=>l.attr0(y[e],y),{}),f=this.reduce((l,y)=>(l.attr0(y[n],[],!1).attr0(y[n]).push0(y),l),{}),p=this.length&&c?this.find(l=>l[n]===0):{[e]:0,[n]:-1,[r]:null,[u]:null,[s]:f[0]};h(p,{[r]:p});for(const l of this)h(l,{[r]:p,[u]:g[l[n]]}),l[s]=f[l[e]]||o;return p.treeEach0(l=>l[i]=l[u]?l[u][i]+1:0,-1,s),p},tree2tree:function(t={},e=null,n=null){const{id:i="id",pid:r="pid",level:u="level",root:s="root",parent:o="parent",children:c="children",empty:g=null}=t;e=e||{[i]:0,[r]:-1,[u]:0,[s]:null,[o]:null,[c]:this},n=n||e;for(const f of this)h(f,{[s]:e,[o]:n}),f[r]=n[i],f[u]=n[u]+1,f[c]=f[c]&&f[c].length?f[c]:g,f[c]?.tree2tree(t,e,f);return e},treeFind0:function(t,e=!0,n=-1,i="children"){for(const r of this){const u=r.treeFind0(t,e,n,i);if(u!==null)return u}return null},treeEach0:function(t,e=!0,n=-1,i="children"){for(const r of this)r.treeEach0(t,e,n,i);return this},treeMap0:function(t,e=!0,n=-1,i="children",r=null){return this.map(u=>u.treeMap0(t,e,n,i,r))}}),h(Map,{...d()}),h(Map.prototype,{...b(["size","length0"]),...m(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]}}),h(Set,{...d()}),h(Set.prototype,{...b(["size","length0"]),...m(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]}}),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(),i=t.getDate(),r=new Date(e,n,i).getTime()/1e3|0;return[r,r+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(),i=t.getDate(),r=new Date(e,n,i).getTime()/1e3|0;return[r,r+86400*7-1]},toMonthRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),i=new Date(e,n,1).getTime()/1e3|0,r=new Date(e,n+1,0,23,59,59).getTime()/1e3|0;return[i,r]},toYearRange:function(){const e=new Date().getFullYear(),n=new Date(e,1,1).getTime()/1e3|0,i=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[n,i]}}),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,i)=>i>="A"&&i<="Z"?e[i.toLowerCase()]:e[i].toString().padStart(i==="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:i=0,i:r=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()+i,this.getMinutes()+r,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((i,r)=>{t=i,e=r}),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={},i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let u=0;u<i.length;u++)n[i.charAt(u)]=u;const r=t.charAt(t.length-1)!="="?t.length:t.charAt(t.length-2)!="="?t.length-1:t.length-2;for(let u=3;u<r;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(r%4==3){const u=(n[t.charAt(r-3)]<<18)+(n[t.charAt(r-2)]<<12)+(n[t.charAt(r-1)]<<6);e.push((u&16711680)>>16,(u&65280)>>8)}else if(r%4==2){const u=(n[t.charAt(r-2)]<<18)+(n[t.charAt(r-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 i=(this[n-2]<<16)+(this[n-1]<<8)+this[n];t+=e.charAt((i&16515072)>>18)+e.charAt((i&258048)>>12)+e.charAt((i&4032)>>6)+e.charAt(i&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",i="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const r=[];for(let u=0;u<t;u++)r.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),r[s]=i.charAt(Math.random()*i.length|0)}return r.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(r,{slots:u}){return e=u.default,()=>{}},name:t+"Template"},i={setup(r,{attrs:u}){return()=>e?.(u)},name:t};return{[n.name]:n,[i.name]:i}}})}));
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 a(t,e,n,...r){const i={};for(const[u,o]of r){if(e===null&&n===null){i[o]=function(...s){return t[u].apply(this,s)};continue}if(e===null&&n===!1){i[o]=function(...s){return t[u].apply(this,s),this};continue}if(e===null&&n===!0){i[o]=function(...s){return t[u].apply(this,s),s};continue}if(e===null&&n>0){i[o]=function(...s){return t[u].apply(this,s),s[n-1]};continue}if(e===null&&n<0){i[o]=function(...s){return t[u].apply(this,s),s[s.length+n+1]};continue}if(e!==null&&n===null){i[o]=function(...s){return s.splice(e>0?e-1:s.length+e+1,0,this),t[u].apply(this,s)};continue}if(e!==null&&n===!1){i[o]=function(...s){return s.splice(e>0?e-1:s.length+e+1,0,this),t[u].apply(this,s),this};continue}if(e!==null&&n===!0){i[o]=function(...s){return s.splice(e>0?e-1:s.length+e+1,0,this),t[u].apply(this,s),s};continue}if(e!==null&&n>0){i[o]=function(...s){return s.splice(e>0?e-1:s.length+e+1,0,this),t[u].apply(this,s),s[n-1]};continue}if(e!==null&&n<0){i[o]=function(...s){return s.splice(e>0?e-1:s.length+e+1,0,this),t[u].apply(this,s),s[s.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 o=Object.prototype.toString.call(i),s=Object.prototype.toString.call(u);if(o!==s)return u;if(o==="[object Array]")return t.array?i.concat(...u):u;if(o==="[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},...a(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){if(typeof this!="object")return this;const[e,n,r,i]=t;return t.length==1?this[e]:t.length==2?(this[e]=n,this):typeof r=="boolean"?(e in this===r&&(this[e]=n),this):r=="define"||r===null?Object.defineProperty(this,e,{value:n,enumerable:!1,configurable:!0,writable:!0,...i}):r==="+"?(this[e]=(this[e]??i??0)+n,this):r==="-"?(this[e]=(this[e]??i??0)-n,this):r==="*"?(this[e]=(this[e]??i??0)*n,this):r==="/"?(this[e]=(this[e]??i??0)/n,this):this},pipe0:function(t,...e){return t(this,...e)},handle0:function(t,...e){return t(this,...e),this},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){console.debug(this,...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,o,s)=>{if(o&&r.push(u),!(s==0||!u[n]||u[n].length==0))for(const l of u[n])i(l,!0,s-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,o=[];if(n==0||!this[r]||this[r].length==0)return u;for(const s of this[r])o.push(s.treeMap0(t,!0,n-1,r,i));return u[r]=o,u}}),h(Number.prototype,{...a(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 o=0;o<n&&r!=-1;o++,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 o=0;o<n&&r!=-1;o++,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(),range:function(...t){let e=[],n=0,r=0,i=1,u=typeof t[t.length-1]=="boolean"?t.pop():!0,o=typeof t[t.length-1]=="function"?t.pop():(s,l,g)=>s;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 s=0,l=0,g=Math.abs(r-n),f=Math.abs(i),p=n<=r?1:-1;l<g;l+=f)e.push(u?o(n+l*p,s++,e):o());return e}}),h(Array.prototype,{...b(["length","length0"]),...m(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:o="children",empty:s=null,hasRoot:l=!0}=t,g=this.reduce((c,y)=>c.attr0(y[e],y),{}),f=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,[o]:f[0]};h(p,{[i]:p});for(const c of this)h(c,{[i]:p,[u]:g[c[n]]}),c[o]=f[c[e]]||s;return p.treeEach0(c=>c[r]=c[u]?c[u][r]+1:0,-1,o),p},tree2tree:function(t={},e=null,n=null){const{id:r="id",pid:i="pid",level:u="level",root:o="root",parent:s="parent",children:l="children",empty:g=null}=t;e=e||{[r]:0,[i]:-1,[u]:0,[o]:null,[s]:null,[l]:this},n=n||e;for(const f of this)h(f,{[o]:e,[s]:n}),f[i]=n[r],f[u]=n[u]+1,f[l]=f[l]&&f[l].length?f[l]:g,f[l]?.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))}}),h(Map,{...d()}),h(Map.prototype,{...b(["size","length0"]),...m(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]}}),h(Set,{...d()}),h(Set.prototype,{...b(["size","length0"]),...m(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]}}),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 o=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(o.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 o=(n[t.charAt(u-3)]<<18)+(n[t.charAt(u-2)]<<12)+(n[t.charAt(u-1)]<<6)+n[t.charAt(u)];e.push((o&16711680)>>16,(o&65280)>>8,o&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,o=0,s=0;s<e;s++){do o=Math.random()*t|0;while(u.has(o));u.set(o,!0),i[o]=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.4",
3
+ "version": "1.5.6",
4
4
  "description": "esexts",
5
5
  "author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
6
6
  "homepage": "https://github.com/dotcoo/esexts#readme",