esexts 1.1.16 → 1.2.1

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,4 +1,4 @@
1
- function g(e = { array: !1 }) {
1
+ function h(e = { array: !1 }) {
2
2
  return function(t = {}, ...r) {
3
3
  const u = (n, l) => {
4
4
  const a = Object.prototype.toString.call(n), s = Object.prototype.toString.call(l);
@@ -18,7 +18,7 @@ function g(e = { array: !1 }) {
18
18
  return t;
19
19
  };
20
20
  }
21
- const m = g({ array: !1 }), w = g({ array: !0 });
21
+ const g = h({ array: !1 }), m = h({ array: !0 });
22
22
  Object.defineProperties(Object, {
23
23
  isObject: {
24
24
  value: function(e) {
@@ -30,7 +30,7 @@ Object.defineProperties(Object, {
30
30
  },
31
31
  merge0: {
32
32
  value: function(...e) {
33
- return m(this, ...e);
33
+ return g(this, ...e);
34
34
  },
35
35
  enumerable: !1,
36
36
  configurable: !0,
@@ -38,7 +38,7 @@ Object.defineProperties(Object, {
38
38
  },
39
39
  concat0: {
40
40
  value: function(...e) {
41
- return w(this, ...e);
41
+ return m(this, ...e);
42
42
  },
43
43
  enumerable: !1,
44
44
  configurable: !0,
@@ -88,7 +88,7 @@ Object.defineProperties(Object.prototype, {
88
88
  },
89
89
  merge0: {
90
90
  value: function(...e) {
91
- return m(this, ...e);
91
+ return g(this, ...e);
92
92
  },
93
93
  enumerable: !1,
94
94
  configurable: !0,
@@ -96,7 +96,7 @@ Object.defineProperties(Object.prototype, {
96
96
  },
97
97
  concat0: {
98
98
  value: function(...e) {
99
- return w(this, ...e);
99
+ return m(this, ...e);
100
100
  },
101
101
  enumerable: !1,
102
102
  configurable: !0,
@@ -160,7 +160,8 @@ Object.defineProperties(Object.prototype, {
160
160
  getParents0: {
161
161
  value: function(e = !1, t = -1, r = "parent") {
162
162
  const u = e ? [this] : [];
163
- for (let n = this[r], l = t; l != 0 && n; l--)
163
+ let n = this[r];
164
+ for (; n && t-- != 0; )
164
165
  u.push(n), n = n[r];
165
166
  return u;
166
167
  },
@@ -170,25 +171,26 @@ Object.defineProperties(Object.prototype, {
170
171
  },
171
172
  getChildrens0: {
172
173
  value: function(e = !1, t = -1, r = "children") {
173
- this[r] = this[r] || [];
174
- const u = e ? [this] : [];
175
- if (t == 0)
176
- return u;
177
- for (const n of this[r])
178
- u.push(...n.getChildrens0(!0, t - 1, r));
179
- return u;
174
+ const u = [], n = (l, a, s) => {
175
+ if (a && u.push(l), !(s == 0 || !l[r] || l[r].length == 0))
176
+ for (const o of l[r])
177
+ n(o, !0, s - 1);
178
+ };
179
+ return n(this, e, t), u;
180
180
  },
181
181
  enumerable: !1,
182
182
  configurable: !0,
183
183
  writable: !0
184
184
  },
185
185
  treeFind0: {
186
- value: function(e, t = !1, r = -1, u = "children") {
187
- if (t && r != 0 && e(this))
186
+ value: function(e, t = !0, r = -1, u = "children") {
187
+ if (t && e(this))
188
188
  return this;
189
- for (const n of this[u] ?? []) {
189
+ if (r == 0 || !this[u] || this[u].length == 0)
190
+ return null;
191
+ for (const n of this[u]) {
190
192
  const l = n.treeFind0(e, !0, r - 1, u);
191
- if (l)
193
+ if (l !== null)
192
194
  return l;
193
195
  }
194
196
  return null;
@@ -196,6 +198,31 @@ Object.defineProperties(Object.prototype, {
196
198
  enumerable: !1,
197
199
  configurable: !0,
198
200
  writable: !0
201
+ },
202
+ treeEach0: {
203
+ value: function(e, t = !0, r = -1, u = "children") {
204
+ if (t && e(this), !(r == 0 || !this[u] || this[u].length == 0)) {
205
+ for (const n of this[u])
206
+ n.treeEach0(e, !0, r - 1, u);
207
+ return this;
208
+ }
209
+ },
210
+ enumerable: !1,
211
+ configurable: !0,
212
+ writable: !0
213
+ },
214
+ treeMap0: {
215
+ value: function(e, t = !0, r = -1, u = "children", n = []) {
216
+ const l = t ? e(this) : this, a = [];
217
+ if (r == 0 || !this[u] || this[u].length == 0)
218
+ return l;
219
+ for (const s of this[u])
220
+ a.push(s.treeMap0(e, !0, r - 1, u, n));
221
+ return l[u] = a, l;
222
+ },
223
+ enumerable: !1,
224
+ configurable: !0,
225
+ writable: !0
199
226
  }
200
227
  });
201
228
  Object.defineProperties(Number.prototype, {
@@ -777,71 +804,61 @@ Object.defineProperties(Array.prototype, {
777
804
  // ====== Tree ======
778
805
  toTree: {
779
806
  value: function(e = {}) {
780
- const { id: t = "id", pid: r = "pid", tid: u = "tid", level: n = "level", parent: l = "parent", children: a = "children", root: s = "root", empty: o = null } = e, c = this.find((i) => i[u] && i[u] == i[t]), b = [], f = this.toObject((i) => [i[t], i]), p = this.toGroup((i) => [i[r], i]);
807
+ const { tid: t = "tid", id: r = "id", pid: u = "pid", level: n = "level", root: l = "root", parent: a = "parent", children: s = "children", empty: o = [] } = e, f = this.toObject((i) => [i[r], i]), c = this.toGroup((i) => [i[u], i]), b = this.length && t in this[0] ? this.find((i) => i[u] === 0) : { [r]: 0, [u]: -1, [l]: null, [a]: null, [s]: c[0] };
808
+ f[b.id] = b;
781
809
  for (const i of this)
782
810
  Object.defineProperties(i, {
783
- [s]: { value: c, enumerable: !1, configurable: !0, writable: !0 },
784
- [l]: { value: f[i[r]] ?? null, enumerable: !1, configurable: !0, writable: !0 }
785
- }), i[n] = null, i[a] = p[i[t]] ?? o, i[r] === ((c == null ? void 0 : c[t]) ?? 0) && b.push(i);
786
- return b.treeEach((i) => {
787
- var h;
788
- return i[n] = (((h = i[l]) == null ? void 0 : h[n]) ?? 0) + 1;
789
- }, { children: a, empty: o }), c ?? b;
811
+ [l]: { value: b, enumerable: !1, configurable: !0, writable: !0 },
812
+ [a]: { value: f[i[u]], enumerable: !1, configurable: !0, writable: !0 }
813
+ }), i[s] = c[i[r]] ?? o;
814
+ return b.treeEach0((i) => i[n] = i[a] ? i[a][n] + 1 : 0, -1, s), b;
790
815
  },
791
816
  enumerable: !1,
792
817
  configurable: !0,
793
818
  writable: !0
794
819
  },
795
- treeEach: {
796
- value: function(e = (r) => r, t = {}) {
797
- const { children: r = "children", empty: u = null } = t;
798
- return this.each0((n, l, a) => {
799
- var s;
800
- n[r] = n[r] || u, e(n, l, a), (s = n[r]) == null || s.treeEach(e, t);
801
- });
820
+ tree2tree: {
821
+ value: function(e = {}, t = null, r = null) {
822
+ var b;
823
+ const { tid: u = "tid", id: n = "id", pid: l = "pid", level: a = "level", root: s = "root", parent: o = "parent", children: f = "children", empty: c = [] } = e;
824
+ t = t ?? { [n]: 0, [l]: -1, [a]: 0, [s]: null, [o]: null, [f]: this }, r = r ?? t;
825
+ for (const i of this)
826
+ Object.defineProperties(i, {
827
+ [s]: { value: t, enumerable: !1, configurable: !0, writable: !0 },
828
+ [o]: { value: r, enumerable: !1, configurable: !0, writable: !0 }
829
+ }), i[l] = r[n], i[a] = r[a] + 1, i[f] = i[f] && i[f].length ? i[f] : c, (b = i[f]) == null || b.tree2tree(e, t, i);
830
+ return t;
802
831
  },
803
832
  enumerable: !1,
804
833
  configurable: !0,
805
834
  writable: !0
806
835
  },
807
- treeMap: {
808
- value: function(e = (r) => r, t = {}) {
809
- const { children: r = "children", empty: u = null } = t;
810
- return this.map((n, l, a) => {
811
- var s;
812
- return n[r] = n[r] || u, n = e(n, l, a), n[r] = ((s = n[r]) == null ? void 0 : s.treeMap(e, t)) ?? u, n;
813
- });
836
+ treeFind0: {
837
+ value: function(e, t = !0, r = -1, u = "children") {
838
+ for (const n of this) {
839
+ const l = n.treeFind0(e, t, r, u);
840
+ if (l !== null)
841
+ return l;
842
+ }
843
+ return null;
814
844
  },
815
845
  enumerable: !1,
816
846
  configurable: !0,
817
847
  writable: !0
818
848
  },
819
- tree2tree: {
820
- value: function(e = null, t = null, r = {}) {
821
- var b;
822
- const { id: u = "id", pid: n = "pid", level: l = "level", parent: a = "parent", children: s = "children", root: o = "root", empty: c = null } = r;
823
- for (const f of this)
824
- Object.defineProperties(f, {
825
- [o]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
826
- [a]: { value: t, enumerable: !1, configurable: !0, writable: !0 }
827
- }), f[n] = (t == null ? void 0 : t[u]) ?? null, f[l] = ((t == null ? void 0 : t[l]) ?? -1) + 1, f[s] = ((b = f[s]) == null ? void 0 : b.tree2tree(e, f, r)) ?? c;
849
+ treeEach0: {
850
+ value: function(e, t = !0, r = -1, u = "children") {
851
+ for (const n of this)
852
+ n.treeEach0(e, t, r, u);
828
853
  return this;
829
854
  },
830
855
  enumerable: !1,
831
856
  configurable: !0,
832
857
  writable: !0
833
858
  },
834
- treeFind0: {
835
- value: function(e, t = "children") {
836
- var r;
837
- for (const u of this) {
838
- if (e(u))
839
- return u;
840
- const n = (r = u[t]) == null ? void 0 : r.treeFind0(e, t);
841
- if (n)
842
- return n;
843
- }
844
- return null;
859
+ treeMap0: {
860
+ value: function(e, t = !0, r = -1, u = "children", n = []) {
861
+ return this.map((l) => l.treeMap0(e, t, r, u, n));
845
862
  },
846
863
  enumerable: !1,
847
864
  configurable: !0,
@@ -1 +1 @@
1
- (function(h){typeof define=="function"&&define.amd?define(h):h()})(function(){"use strict";function h(e={array:!1}){return function(t={},...r){const u=(n,l)=>{const a=Object.prototype.toString.call(n),s=Object.prototype.toString.call(l);if(a!==s)return l;if(a==="[object Array]")return e.array?n.concat(...l):l;if(a==="[object Object]"){for(const o in l)n[o]=u(n[o],l[o]);return n}else return l};for(const n of r)t=u(t,n);return t}}const g=h({array:!1}),m=h({array:!0});Object.defineProperties(Object,{isObject:{value:function(e){return Object.prototype.toString.call(e)==="[object Object]"},enumerable:!1,configurable:!0,writable:!0},merge0:{value:function(...e){return g(this,...e)},enumerable:!1,configurable:!0,writable:!0},concat0:{value:function(...e){return m(this,...e)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Object.prototype,{clone0:{value:function(){return typeof structuredClone>"u"?JSON.parse(JSON.stringify(this)):structuredClone(this)},enumerable:!1,configurable:!0,writable:!0},length0:{value:function(){return Object.keys(this).length},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return Object.entries(this)},enumerable:!1,configurable:!0,writable:!0},keys0:{value:function(){return Object.keys(this)},enumerable:!1,configurable:!0,writable:!0},values0:{value:function(){return Object.values(this)},enumerable:!1,configurable:!0,writable:!0},merge0:{value:function(...e){return g(this,...e)},enumerable:!1,configurable:!0,writable:!0},concat0:{value:function(...e){return m(this,...e)},enumerable:!1,configurable:!0,writable:!0},map0:{value:function(e=(r,u,n)=>[r,u],t=0){return Object.entries(this).map(([r,u])=>e(r,u,t++))},enumerable:!1,configurable:!0,writable:!0},pick0:{value:function(...e){const t={};for(const r of e)t[r]=this[r];return t},enumerable:!1,configurable:!0,writable:!0},omit0:{value:function(...e){const t={},r=new Set(e);for(const u in this)r.has(u)||(t[u]=this[u]);return t},enumerable:!1,configurable:!0,writable:!0},attr0:{value:function(e,...t){return typeof this!="object"?this:typeof e=="function"?e(this,...t):this[e]},enumerable:!1,configurable:!0,writable:!0},log0:{value:function(...e){return console.log(...e,this),this},enumerable:!1,configurable:!0,writable:!0},debug0:{value:function(...e){return console.debug(...e,this),this},enumerable:!1,configurable:!0,writable:!0},getParents0:{value:function(e=!1,t=-1,r="parent"){const u=e?[this]:[];for(let n=this[r],l=t;l!=0&&n;l--)u.push(n),n=n[r];return u},enumerable:!1,configurable:!0,writable:!0},getChildrens0:{value:function(e=!1,t=-1,r="children"){this[r]=this[r]||[];const u=e?[this]:[];if(t==0)return u;for(const n of this[r])u.push(...n.getChildrens0(!0,t-1,r));return u},enumerable:!1,configurable:!0,writable:!0},treeFind0:{value:function(e,t=!1,r=-1,u="children"){if(t&&r!=0&&e(this))return this;for(const n of this[u]??[]){const l=n.treeFind0(e,!0,r-1,u);if(l)return l}return null},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Number.prototype,{ceil:{value:function(){return Math.ceil(this)},enumerable:!1,configurable:!0,writable:!0},floor:{value:function(){return Math.floor(this)},enumerable:!1,configurable:!0,writable:!0},round:{value:function(e=0){return e==0?Math.round(this):Math.round(this*10**e)/10**e},enumerable:!1,configurable:!0,writable:!0},trunc:{value:function(){return Math.trunc(this)},enumerable:!1,configurable:!0,writable:!0},abs:{value:function(){return Math.abs(this)},enumerable:!1,configurable:!0,writable:!0},max:{value:function(...e){return Math.max(this,...e)},enumerable:!1,configurable:!0,writable:!0},min:{value:function(...e){return Math.min(this,...e)},enumerable:!1,configurable:!0,writable:!0},b64:{value:function(){let e="",t=this,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";for(;t>0;)e=r.at(t%64)+e,t=Math.floor(t/64);return e},enumerable:!1,configurable:!0,writable:!0},toFixed0:{value:function(...e){return+this.toFixed(...e)},enumerable:!1,configurable:!0,writable:!0},toDate:{value:function(){return Date.new(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(String.prototype,{length0:{value:function(){return this.length},enumerable:!1,configurable:!0,writable:!0},substring0:{value:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},enumerable:!1,configurable:!0,writable:!0},substr0:{value:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},enumerable:!1,configurable:!0,writable:!0},split0:{value:function(e=",",t=-1){const r=this?this.split(e):[];return t===-1?r:r.push0(r.splice(t-1).join(e))},enumerable:!1,configurable:!0,writable:!0},splitNumber:{value:function(e=","){return this.split0(e).map(t=>+t)},enumerable:!1,configurable:!0,writable:!0},splitSegment:{value:function(e=1){const t=[];for(let r=0;r<this.length;r+=e)t.push(this.substring(r,e));return t},enumerable:!1,configurable:!0,writable:!0},sprintf:{value:function(...e){let[t,...r]=this.split(/%[sd]/);for(let u=0;u<r.length;u++)t+=e[u]+r[u];return t},enumerable:!1,configurable:!0,writable:!0},subOf:{value:function(e,t,r=0,u=0){for(let a=0;a<r&&u!=-1;a++,u++)u=this.indexOf(e,u);let n=this.indexOf(e,u),l=this.indexOf(t,n);return n==-1||l==-1?"":(n+=e.length,this.substring(n,l))},enumerable:!1,configurable:!0,writable:!0},lastSubOf:{value:function(e,t,r=0,u=1/0){for(let a=0;a<r&&u!=-1;a++,u--)u=this.lastIndexOf(e,u);let n=this.lastIndexOf(e,u),l=this.indexOf(t,n);return n==-1||l==-1?"":(n+=e.length,this.substring(n,l))},enumerable:!1,configurable:!0,writable:!0},camel2under:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1).replace(/([A-Z])/g,(e,t)=>"_"+t.toLowerCase())},enumerable:!1,configurable:!0,writable:!0},under2camel:{value:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},enumerable:!1,configurable:!0,writable:!0},camel2pascal:{value:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},enumerable:!1,configurable:!0,writable:!0},pascal2camel:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},enumerable:!1,configurable:!0,writable:!0},under2kebab:{value:function(){return this.replace(/_/g,"-")},enumerable:!1,configurable:!0,writable:!0},kebab2under:{value:function(){return this.replace(/-/g,"_")},enumerable:!1,configurable:!0,writable:!0},b64:{value:function(){let e=0,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";for(let r=0;r<this.length;r++)e=e*64+t.indexOf(this.at(r));return e},enumerable:!1,configurable:!0,writable:!0},toFixed0:{value:function(...e){return+(+this).toFixed(...e)},enumerable:!1,configurable:!0,writable:!0},toDate:{value:function(){return Date.new(this)},enumerable:!1,configurable:!0,writable:!0},hex2bytes:{value:function(){const e=[];for(let t=0;t<this.length;t+=2)e.push(Number.parseInt(this.substring(t,t+2),16));return e},enumerable:!1,configurable:!0,writable:!0},string2bytes:{value:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const e=[],t=encodeURIComponent(this);for(let r=0;r<t.length;)e.push(t.charAt(r)=="%"?Number.parseInt(t.substring(r+1,r+=3),16):t.charCodeAt(r++));return e},enumerable:!1,configurable:!0,writable:!0},base64decode:{value:function(e){const t=[],r={},u=e===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let l=0;l<u.length;l++)r[u.charAt(l)]=l;const n=this.charAt(this.length-1)!="="?this.length:this.charAt(this.length-2)!="="?this.length-1:this.length-2;for(let l=3;l<n;l+=4){const a=(r[this.charAt(l-3)]<<18)+(r[this.charAt(l-2)]<<12)+(r[this.charAt(l-1)]<<6)+r[this.charAt(l)];t.push((a&16711680)>>16,(a&65280)>>8,a&255)}if(n%4==3){const l=(r[this.charAt(n-3)]<<18)+(r[this.charAt(n-2)]<<12)+(r[this.charAt(n-1)]<<6);t.push((l&16711680)>>16,(l&65280)>>8)}else if(n%4==2){const l=(r[this.charAt(n-2)]<<18)+(r[this.charAt(n-1)]<<12);t.push((l&16711680)>>16)}return t},enumerable:!1,configurable:!0,writable:!0}}),typeof Iterator<"u"&&Object.defineProperties(Iterator.prototype,{toArray:{value:function(){return Array.from(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Array.prototype,{length0:{value:function(){return this.length},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return this.entries()},enumerable:!1,configurable:!0,writable:!0},push0:{value:function(...e){return this.push(...e),this},enumerable:!1,configurable:!0,writable:!0},push1:{value:function(...e){return this.push(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},push3:{value:function(...e){return this.push(...e),e},enumerable:!1,configurable:!0,writable:!0},pop0:{value:function(...e){return this.pop(...e),this},enumerable:!1,configurable:!0,writable:!0},pop1:{value:function(...e){return this.pop(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},pop3:{value:function(...e){return this.pop(...e),e},enumerable:!1,configurable:!0,writable:!0},unshift0:{value:function(...e){return this.unshift(...e),this},enumerable:!1,configurable:!0,writable:!0},unshift1:{value:function(...e){return this.unshift(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},unshift3:{value:function(...e){return this.unshift(...e),e},enumerable:!1,configurable:!0,writable:!0},shift0:{value:function(...e){return this.shift(...e),this},enumerable:!1,configurable:!0,writable:!0},shift1:{value:function(...e){return this.shift(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},shift3:{value:function(...e){return this.shift(...e),e},enumerable:!1,configurable:!0,writable:!0},first0:{value:function(e=null){return this.length?this[0]:e},enumerable:!1,configurable:!0,writable:!0},last0:{value:function(e=null){return this.length?this[this.length-1]:e},enumerable:!1,configurable:!0,writable:!0},find0:{value:function(e,t=null){return this.find(e)??t},enumerable:!1,configurable:!0,writable:!0},equals0:{value:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,r)=>t===e[r]))},enumerable:!1,configurable:!0,writable:!0},unique0:{value:function(e=t=>t){const t=new Set;return this.filter(r=>t.has(e(r))?!1:!!t.add(e(r)))},enumerable:!1,configurable:!0,writable:!0},each0:{value:function(e){return this.forEach(e),this},enumerable:!1,configurable:!0,writable:!0},toObject:{value:function(e=(t,r)=>[r,t]){return Object.fromEntries(this.map(e))},enumerable:!1,configurable:!0,writable:!0},toMap:{value:function(e=(t,r)=>[r,t]){return new Map(this.map(e))},enumerable:!1,configurable:!0,writable:!0},toSet:{value:function(){return new Set(this)},enumerable:!1,configurable:!0,writable:!0},toGroup:{value:function(e=t=>[t.id,t]){const t={};for(const r of this){const[u,n]=e(r);u in t||(t[u]=[]),t[u].push(n)}return t},enumerable:!1,configurable:!0,writable:!0},toMerge:{value:function(e=u=>u.id,t=u=>({...u,children:u.children||[]}),r=(u,n)=>u.children.push(n)){const u=[];for(const n of this)r(u.find(l=>e(l)==e(n))??u.push1(t(n)),n);return u},enumerable:!1,configurable:!0,writable:!0},bytes2hex:{value:function(){let e="";for(let t=0;t<this.length;t++)e+=(this[t]<16?"0":"")+this[t].toString(16);return e},enumerable:!1,configurable:!0,writable:!0},bytes2string:{value:function(){if(typeof TextDecoder<"u")return new TextDecoder().decode(new Uint8Array(this));let e="";for(let t=0;t<this.length;t++)e+="%"+(this[t]<16?"0":"")+this[t].toString(16);return decodeURIComponent(e)},enumerable:!1,configurable:!0,writable:!0},base64encode:{value:function(e,t){let r="",u=e===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const l=(this[n-2]<<16)+(this[n-1]<<8)+this[n];r+=u.charAt((l&16515072)>>18)+u.charAt((l&258048)>>12)+u.charAt((l&4032)>>6)+u.charAt(l&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);r+=u.charAt((n&16515072)>>18)+u.charAt((n&258048)>>12)+u.charAt((n&4032)>>6)+(t===!1?"":"=")}else if(this.length%3==1){const n=this[this.length-1]<<16;r+=u.charAt((n&16515072)>>18)+u.charAt((n&258048)>>12)+(t===!1?"":"==")}return r},enumerable:!1,configurable:!0,writable:!0},toUint8Array:{value:function(){return new Uint8Array(this)},enumerable:!1,configurable:!0,writable:!0},assoc:{value:function(e,t,r={}){const u=this.unique0(l=>l[e]),n=u.length==0?{}:typeof r=="function"?r(u):r;return this.each0(l=>l[t]=n[l[e]]??null)},enumerable:!1,configurable:!0,writable:!0},toTree:{value:function(e={}){const{id:t="id",pid:r="pid",tid:u="tid",level:n="level",parent:l="parent",children:a="children",root:s="root",empty:o=null}=e,c=this.find(i=>i[u]&&i[u]==i[t]),b=[],f=this.toObject(i=>[i[t],i]),p=this.toGroup(i=>[i[r],i]);for(const i of this)Object.defineProperties(i,{[s]:{value:c,enumerable:!1,configurable:!0,writable:!0},[l]:{value:f[i[r]]??null,enumerable:!1,configurable:!0,writable:!0}}),i[n]=null,i[a]=p[i[t]]??o,i[r]===((c==null?void 0:c[t])??0)&&b.push(i);return b.treeEach(i=>{var w;return i[n]=(((w=i[l])==null?void 0:w[n])??0)+1},{children:a,empty:o}),c??b},enumerable:!1,configurable:!0,writable:!0},treeEach:{value:function(e=r=>r,t={}){const{children:r="children",empty:u=null}=t;return this.each0((n,l,a)=>{var s;n[r]=n[r]||u,e(n,l,a),(s=n[r])==null||s.treeEach(e,t)})},enumerable:!1,configurable:!0,writable:!0},treeMap:{value:function(e=r=>r,t={}){const{children:r="children",empty:u=null}=t;return this.map((n,l,a)=>{var s;return n[r]=n[r]||u,n=e(n,l,a),n[r]=((s=n[r])==null?void 0:s.treeMap(e,t))??u,n})},enumerable:!1,configurable:!0,writable:!0},tree2tree:{value:function(e=null,t=null,r={}){var b;const{id:u="id",pid:n="pid",level:l="level",parent:a="parent",children:s="children",root:o="root",empty:c=null}=r;for(const f of this)Object.defineProperties(f,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[a]:{value:t,enumerable:!1,configurable:!0,writable:!0}}),f[n]=(t==null?void 0:t[u])??null,f[l]=((t==null?void 0:t[l])??-1)+1,f[s]=((b=f[s])==null?void 0:b.tree2tree(e,f,r))??c;return this},enumerable:!1,configurable:!0,writable:!0},treeFind0:{value:function(e,t="children"){var r;for(const u of this){if(e(u))return u;const n=(r=u[t])==null?void 0:r.treeFind0(e,t);if(n)return n}return null},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(ArrayBuffer.prototype,{toUint8Array:{value:function(){return new Uint8Array(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Uint8Array.prototype,{bytes2hex:{value:Array.prototype.bytes2hex,enumerable:!1,configurable:!0,writable:!0},bytes2string:{value:Array.prototype.bytes2string,enumerable:!1,configurable:!0,writable:!0},base64encode:{value:Array.prototype.base64encode,enumerable:!1,configurable:!0,writable:!0},toArray:{value:function(){return new Array(...this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Map.prototype,{length0:{value:function(){return this.size},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return[...this.entries()]},enumerable:!1,configurable:!0,writable:!0},keys0:{value:function(){return[...this.keys()]},enumerable:!1,configurable:!0,writable:!0},values0:{value:function(){return[...this.values()]},enumerable:!1,configurable:!0,writable:!0},get0:{value:function(e,t=null,...r){if(this.has(e))return this.get(e);const u=typeof t!="function"?t:t(e,...r);return this.set(e,u),u},enumerable:!1,configurable:!0,writable:!0},get1:{value:async function(e,t=null,...r){if(this.has(e))return this.get(e);const u=typeof t!="function"?t:await t(e,...r);return this.set(e,u),u},enumerable:!1,configurable:!0,writable:!0},toObject:{value:function(){return Object.fromEntries(this)},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Set.prototype,{length0:{value:function(){return this.size},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return this.entries()},enumerable:!1,configurable:!0,writable:!0},toArray:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Date,{new:{value:function(...e){return e.length!=1?new Date(...e):Number.isNaN(+e[0])?new Date(e[0].includes("T")?e[0]:e[0].replace(/-/g,"/")):new Date(e[0]>265e7?e[0]:e[0]*1e3)},enumerable:!1,configurable:!0,writable:!0},format:{value:function(e="y-m-d h:i:s"){return new Date().format(e)},enumerable:!1,configurable:!0,writable:!0},unix:{value:function(){return this.now()/1e3|0},enumerable:!1,configurable:!0,writable:!0},fromUnix:{value:function(e=0){return this.new((e||0)*1e3)},enumerable:!1,configurable:!0,writable:!0},expr:{value:function(e={}){return new Date().expr(e)},enumerable:!1,configurable:!0,writable:!0},toDayRange:{value:function(){const e=new Date,t=e.getFullYear(),r=e.getMonth(),u=e.getDate(),n=new Date(t,r,u).getTime()/1e3|0;return[n,n+86400-1]},enumerable:!1,configurable:!0,writable:!0},toWeekRange:{value:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);const t=e.getFullYear(),r=e.getMonth(),u=e.getDate(),n=new Date(t,r,u).getTime()/1e3|0;return[n,n+86400*7-1]},enumerable:!1,configurable:!0,writable:!0},toMonthRange:{value:function(){const e=new Date,t=e.getFullYear(),r=e.getMonth(),u=new Date(t,r,1).getTime()/1e3|0,n=new Date(t,r+1,0,23,59,59).getTime()/1e3|0;return[u,n]},enumerable:!1,configurable:!0,writable:!0},toYearRange:{value:function(){const t=new Date().getFullYear(),r=new Date(t,1,1).getTime()/1e3|0,u=new Date(t+1,1,0,23,59,59).getTime()/1e3|0;return[r,u]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Date.prototype,{format:{value:function(e="y-m-d h:i:s"){if(this.getTime()===0)return"-";const t={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 e.replace(/([ymdhisle])/ig,(r,u)=>u>="A"&&u<="Z"?t[u.toLowerCase()]:t[u].toString().padStart(u==="l"?3:2,"0"))},enumerable:!1,configurable:!0,writable:!0},unix:{value:function(){return this.getTime()/1e3|0},enumerable:!1,configurable:!0,writable:!0},isLeapYear:{value:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},enumerable:!1,configurable:!0,writable:!0},getMonthDay:{value:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},enumerable:!1,configurable:!0,writable:!0},expr:{value:function({y:e=0,m:t=0,d:r=0,h:u=0,i:n=0,s:l=0}){const a=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(a.getDate(),this.getDate())+r,this.getHours()+u,this.getMinutes()+n,this.getSeconds()+l)},enumerable:!1,configurable:!0,writable:!0},begin:{value:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},enumerable:!1,configurable:!0,writable:!0},end:{value:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},enumerable:!1,configurable:!0,writable:!0},week:{value:function(e,t=1){let r=new Date(this.getTime());for(;r.getDay()!==e;)r=new Date(r.getTime()+864e5*t);return r},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return this.getTime()},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(RegExp.prototype,{toJSON:{value:function(){return this.toString()},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Promise.prototype,{tryCatch:{value:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Promise,{channel:{value:function(){let e=null,t=null;return[new this((u,n)=>{e=u,t=n}),e,t]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(JSON,{parse0:{value:function(e,t=null){try{if(typeof e!="string")throw new Error("not string");return JSON.parse(e)}catch{return t}},enumerable:!1,configurable:!0,writable:!0}})});
1
+ (function(c){typeof define=="function"&&define.amd?define(c):c()})(function(){"use strict";function c(e={array:!1}){return function(t={},...r){const u=(n,l)=>{const a=Object.prototype.toString.call(n),s=Object.prototype.toString.call(l);if(a!==s)return l;if(a==="[object Array]")return e.array?n.concat(...l):l;if(a==="[object Object]"){for(const o in l)n[o]=u(n[o],l[o]);return n}else return l};for(const n of r)t=u(t,n);return t}}const g=c({array:!1}),m=c({array:!0});Object.defineProperties(Object,{isObject:{value:function(e){return Object.prototype.toString.call(e)==="[object Object]"},enumerable:!1,configurable:!0,writable:!0},merge0:{value:function(...e){return g(this,...e)},enumerable:!1,configurable:!0,writable:!0},concat0:{value:function(...e){return m(this,...e)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Object.prototype,{clone0:{value:function(){return typeof structuredClone>"u"?JSON.parse(JSON.stringify(this)):structuredClone(this)},enumerable:!1,configurable:!0,writable:!0},length0:{value:function(){return Object.keys(this).length},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return Object.entries(this)},enumerable:!1,configurable:!0,writable:!0},keys0:{value:function(){return Object.keys(this)},enumerable:!1,configurable:!0,writable:!0},values0:{value:function(){return Object.values(this)},enumerable:!1,configurable:!0,writable:!0},merge0:{value:function(...e){return g(this,...e)},enumerable:!1,configurable:!0,writable:!0},concat0:{value:function(...e){return m(this,...e)},enumerable:!1,configurable:!0,writable:!0},map0:{value:function(e=(r,u,n)=>[r,u],t=0){return Object.entries(this).map(([r,u])=>e(r,u,t++))},enumerable:!1,configurable:!0,writable:!0},pick0:{value:function(...e){const t={};for(const r of e)t[r]=this[r];return t},enumerable:!1,configurable:!0,writable:!0},omit0:{value:function(...e){const t={},r=new Set(e);for(const u in this)r.has(u)||(t[u]=this[u]);return t},enumerable:!1,configurable:!0,writable:!0},attr0:{value:function(e,...t){return typeof this!="object"?this:typeof e=="function"?e(this,...t):this[e]},enumerable:!1,configurable:!0,writable:!0},log0:{value:function(...e){return console.log(...e,this),this},enumerable:!1,configurable:!0,writable:!0},debug0:{value:function(...e){return console.debug(...e,this),this},enumerable:!1,configurable:!0,writable:!0},getParents0:{value:function(e=!1,t=-1,r="parent"){const u=e?[this]:[];let n=this[r];for(;n&&t--!=0;)u.push(n),n=n[r];return u},enumerable:!1,configurable:!0,writable:!0},getChildrens0:{value:function(e=!1,t=-1,r="children"){const u=[],n=(l,a,s)=>{if(a&&u.push(l),!(s==0||!l[r]||l[r].length==0))for(const o of l[r])n(o,!0,s-1)};return n(this,e,t),u},enumerable:!1,configurable:!0,writable:!0},treeFind0:{value:function(e,t=!0,r=-1,u="children"){if(t&&e(this))return this;if(r==0||!this[u]||this[u].length==0)return null;for(const n of this[u]){const l=n.treeFind0(e,!0,r-1,u);if(l!==null)return l}return null},enumerable:!1,configurable:!0,writable:!0},treeEach0:{value:function(e,t=!0,r=-1,u="children"){if(t&&e(this),!(r==0||!this[u]||this[u].length==0)){for(const n of this[u])n.treeEach0(e,!0,r-1,u);return this}},enumerable:!1,configurable:!0,writable:!0},treeMap0:{value:function(e,t=!0,r=-1,u="children",n=[]){const l=t?e(this):this,a=[];if(r==0||!this[u]||this[u].length==0)return l;for(const s of this[u])a.push(s.treeMap0(e,!0,r-1,u,n));return l[u]=a,l},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Number.prototype,{ceil:{value:function(){return Math.ceil(this)},enumerable:!1,configurable:!0,writable:!0},floor:{value:function(){return Math.floor(this)},enumerable:!1,configurable:!0,writable:!0},round:{value:function(e=0){return e==0?Math.round(this):Math.round(this*10**e)/10**e},enumerable:!1,configurable:!0,writable:!0},trunc:{value:function(){return Math.trunc(this)},enumerable:!1,configurable:!0,writable:!0},abs:{value:function(){return Math.abs(this)},enumerable:!1,configurable:!0,writable:!0},max:{value:function(...e){return Math.max(this,...e)},enumerable:!1,configurable:!0,writable:!0},min:{value:function(...e){return Math.min(this,...e)},enumerable:!1,configurable:!0,writable:!0},b64:{value:function(){let e="",t=this,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";for(;t>0;)e=r.at(t%64)+e,t=Math.floor(t/64);return e},enumerable:!1,configurable:!0,writable:!0},toFixed0:{value:function(...e){return+this.toFixed(...e)},enumerable:!1,configurable:!0,writable:!0},toDate:{value:function(){return Date.new(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(String.prototype,{length0:{value:function(){return this.length},enumerable:!1,configurable:!0,writable:!0},substring0:{value:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},enumerable:!1,configurable:!0,writable:!0},substr0:{value:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},enumerable:!1,configurable:!0,writable:!0},split0:{value:function(e=",",t=-1){const r=this?this.split(e):[];return t===-1?r:r.push0(r.splice(t-1).join(e))},enumerable:!1,configurable:!0,writable:!0},splitNumber:{value:function(e=","){return this.split0(e).map(t=>+t)},enumerable:!1,configurable:!0,writable:!0},splitSegment:{value:function(e=1){const t=[];for(let r=0;r<this.length;r+=e)t.push(this.substring(r,e));return t},enumerable:!1,configurable:!0,writable:!0},sprintf:{value:function(...e){let[t,...r]=this.split(/%[sd]/);for(let u=0;u<r.length;u++)t+=e[u]+r[u];return t},enumerable:!1,configurable:!0,writable:!0},subOf:{value:function(e,t,r=0,u=0){for(let a=0;a<r&&u!=-1;a++,u++)u=this.indexOf(e,u);let n=this.indexOf(e,u),l=this.indexOf(t,n);return n==-1||l==-1?"":(n+=e.length,this.substring(n,l))},enumerable:!1,configurable:!0,writable:!0},lastSubOf:{value:function(e,t,r=0,u=1/0){for(let a=0;a<r&&u!=-1;a++,u--)u=this.lastIndexOf(e,u);let n=this.lastIndexOf(e,u),l=this.indexOf(t,n);return n==-1||l==-1?"":(n+=e.length,this.substring(n,l))},enumerable:!1,configurable:!0,writable:!0},camel2under:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1).replace(/([A-Z])/g,(e,t)=>"_"+t.toLowerCase())},enumerable:!1,configurable:!0,writable:!0},under2camel:{value:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},enumerable:!1,configurable:!0,writable:!0},camel2pascal:{value:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},enumerable:!1,configurable:!0,writable:!0},pascal2camel:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},enumerable:!1,configurable:!0,writable:!0},under2kebab:{value:function(){return this.replace(/_/g,"-")},enumerable:!1,configurable:!0,writable:!0},kebab2under:{value:function(){return this.replace(/-/g,"_")},enumerable:!1,configurable:!0,writable:!0},b64:{value:function(){let e=0,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";for(let r=0;r<this.length;r++)e=e*64+t.indexOf(this.at(r));return e},enumerable:!1,configurable:!0,writable:!0},toFixed0:{value:function(...e){return+(+this).toFixed(...e)},enumerable:!1,configurable:!0,writable:!0},toDate:{value:function(){return Date.new(this)},enumerable:!1,configurable:!0,writable:!0},hex2bytes:{value:function(){const e=[];for(let t=0;t<this.length;t+=2)e.push(Number.parseInt(this.substring(t,t+2),16));return e},enumerable:!1,configurable:!0,writable:!0},string2bytes:{value:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const e=[],t=encodeURIComponent(this);for(let r=0;r<t.length;)e.push(t.charAt(r)=="%"?Number.parseInt(t.substring(r+1,r+=3),16):t.charCodeAt(r++));return e},enumerable:!1,configurable:!0,writable:!0},base64decode:{value:function(e){const t=[],r={},u=e===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let l=0;l<u.length;l++)r[u.charAt(l)]=l;const n=this.charAt(this.length-1)!="="?this.length:this.charAt(this.length-2)!="="?this.length-1:this.length-2;for(let l=3;l<n;l+=4){const a=(r[this.charAt(l-3)]<<18)+(r[this.charAt(l-2)]<<12)+(r[this.charAt(l-1)]<<6)+r[this.charAt(l)];t.push((a&16711680)>>16,(a&65280)>>8,a&255)}if(n%4==3){const l=(r[this.charAt(n-3)]<<18)+(r[this.charAt(n-2)]<<12)+(r[this.charAt(n-1)]<<6);t.push((l&16711680)>>16,(l&65280)>>8)}else if(n%4==2){const l=(r[this.charAt(n-2)]<<18)+(r[this.charAt(n-1)]<<12);t.push((l&16711680)>>16)}return t},enumerable:!1,configurable:!0,writable:!0}}),typeof Iterator<"u"&&Object.defineProperties(Iterator.prototype,{toArray:{value:function(){return Array.from(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Array.prototype,{length0:{value:function(){return this.length},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return this.entries()},enumerable:!1,configurable:!0,writable:!0},push0:{value:function(...e){return this.push(...e),this},enumerable:!1,configurable:!0,writable:!0},push1:{value:function(...e){return this.push(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},push3:{value:function(...e){return this.push(...e),e},enumerable:!1,configurable:!0,writable:!0},pop0:{value:function(...e){return this.pop(...e),this},enumerable:!1,configurable:!0,writable:!0},pop1:{value:function(...e){return this.pop(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},pop3:{value:function(...e){return this.pop(...e),e},enumerable:!1,configurable:!0,writable:!0},unshift0:{value:function(...e){return this.unshift(...e),this},enumerable:!1,configurable:!0,writable:!0},unshift1:{value:function(...e){return this.unshift(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},unshift3:{value:function(...e){return this.unshift(...e),e},enumerable:!1,configurable:!0,writable:!0},shift0:{value:function(...e){return this.shift(...e),this},enumerable:!1,configurable:!0,writable:!0},shift1:{value:function(...e){return this.shift(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},shift3:{value:function(...e){return this.shift(...e),e},enumerable:!1,configurable:!0,writable:!0},first0:{value:function(e=null){return this.length?this[0]:e},enumerable:!1,configurable:!0,writable:!0},last0:{value:function(e=null){return this.length?this[this.length-1]:e},enumerable:!1,configurable:!0,writable:!0},find0:{value:function(e,t=null){return this.find(e)??t},enumerable:!1,configurable:!0,writable:!0},equals0:{value:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,r)=>t===e[r]))},enumerable:!1,configurable:!0,writable:!0},unique0:{value:function(e=t=>t){const t=new Set;return this.filter(r=>t.has(e(r))?!1:!!t.add(e(r)))},enumerable:!1,configurable:!0,writable:!0},each0:{value:function(e){return this.forEach(e),this},enumerable:!1,configurable:!0,writable:!0},toObject:{value:function(e=(t,r)=>[r,t]){return Object.fromEntries(this.map(e))},enumerable:!1,configurable:!0,writable:!0},toMap:{value:function(e=(t,r)=>[r,t]){return new Map(this.map(e))},enumerable:!1,configurable:!0,writable:!0},toSet:{value:function(){return new Set(this)},enumerable:!1,configurable:!0,writable:!0},toGroup:{value:function(e=t=>[t.id,t]){const t={};for(const r of this){const[u,n]=e(r);u in t||(t[u]=[]),t[u].push(n)}return t},enumerable:!1,configurable:!0,writable:!0},toMerge:{value:function(e=u=>u.id,t=u=>({...u,children:u.children||[]}),r=(u,n)=>u.children.push(n)){const u=[];for(const n of this)r(u.find(l=>e(l)==e(n))??u.push1(t(n)),n);return u},enumerable:!1,configurable:!0,writable:!0},bytes2hex:{value:function(){let e="";for(let t=0;t<this.length;t++)e+=(this[t]<16?"0":"")+this[t].toString(16);return e},enumerable:!1,configurable:!0,writable:!0},bytes2string:{value:function(){if(typeof TextDecoder<"u")return new TextDecoder().decode(new Uint8Array(this));let e="";for(let t=0;t<this.length;t++)e+="%"+(this[t]<16?"0":"")+this[t].toString(16);return decodeURIComponent(e)},enumerable:!1,configurable:!0,writable:!0},base64encode:{value:function(e,t){let r="",u=e===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const l=(this[n-2]<<16)+(this[n-1]<<8)+this[n];r+=u.charAt((l&16515072)>>18)+u.charAt((l&258048)>>12)+u.charAt((l&4032)>>6)+u.charAt(l&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);r+=u.charAt((n&16515072)>>18)+u.charAt((n&258048)>>12)+u.charAt((n&4032)>>6)+(t===!1?"":"=")}else if(this.length%3==1){const n=this[this.length-1]<<16;r+=u.charAt((n&16515072)>>18)+u.charAt((n&258048)>>12)+(t===!1?"":"==")}return r},enumerable:!1,configurable:!0,writable:!0},toUint8Array:{value:function(){return new Uint8Array(this)},enumerable:!1,configurable:!0,writable:!0},assoc:{value:function(e,t,r={}){const u=this.unique0(l=>l[e]),n=u.length==0?{}:typeof r=="function"?r(u):r;return this.each0(l=>l[t]=n[l[e]]??null)},enumerable:!1,configurable:!0,writable:!0},toTree:{value:function(e={}){const{tid:t="tid",id:r="id",pid:u="pid",level:n="level",root:l="root",parent:a="parent",children:s="children",empty:o=[]}=e,f=this.toObject(i=>[i[r],i]),h=this.toGroup(i=>[i[u],i]),b=this.length&&t in this[0]?this.find(i=>i[u]===0):{[r]:0,[u]:-1,[l]:null,[a]:null,[s]:h[0]};f[b.id]=b;for(const i of this)Object.defineProperties(i,{[l]:{value:b,enumerable:!1,configurable:!0,writable:!0},[a]:{value:f[i[u]],enumerable:!1,configurable:!0,writable:!0}}),i[s]=h[i[r]]??o;return b.treeEach0(i=>i[n]=i[a]?i[a][n]+1:0,-1,s),b},enumerable:!1,configurable:!0,writable:!0},tree2tree:{value:function(e={},t=null,r=null){var b;const{tid:u="tid",id:n="id",pid:l="pid",level:a="level",root:s="root",parent:o="parent",children:f="children",empty:h=[]}=e;t=t??{[n]:0,[l]:-1,[a]:0,[s]:null,[o]:null,[f]:this},r=r??t;for(const i of this)Object.defineProperties(i,{[s]:{value:t,enumerable:!1,configurable:!0,writable:!0},[o]:{value:r,enumerable:!1,configurable:!0,writable:!0}}),i[l]=r[n],i[a]=r[a]+1,i[f]=i[f]&&i[f].length?i[f]:h,(b=i[f])==null||b.tree2tree(e,t,i);return t},enumerable:!1,configurable:!0,writable:!0},treeFind0:{value:function(e,t=!0,r=-1,u="children"){for(const n of this){const l=n.treeFind0(e,t,r,u);if(l!==null)return l}return null},enumerable:!1,configurable:!0,writable:!0},treeEach0:{value:function(e,t=!0,r=-1,u="children"){for(const n of this)n.treeEach0(e,t,r,u);return this},enumerable:!1,configurable:!0,writable:!0},treeMap0:{value:function(e,t=!0,r=-1,u="children",n=[]){return this.map(l=>l.treeMap0(e,t,r,u,n))},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(ArrayBuffer.prototype,{toUint8Array:{value:function(){return new Uint8Array(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Uint8Array.prototype,{bytes2hex:{value:Array.prototype.bytes2hex,enumerable:!1,configurable:!0,writable:!0},bytes2string:{value:Array.prototype.bytes2string,enumerable:!1,configurable:!0,writable:!0},base64encode:{value:Array.prototype.base64encode,enumerable:!1,configurable:!0,writable:!0},toArray:{value:function(){return new Array(...this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Map.prototype,{length0:{value:function(){return this.size},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return[...this.entries()]},enumerable:!1,configurable:!0,writable:!0},keys0:{value:function(){return[...this.keys()]},enumerable:!1,configurable:!0,writable:!0},values0:{value:function(){return[...this.values()]},enumerable:!1,configurable:!0,writable:!0},get0:{value:function(e,t=null,...r){if(this.has(e))return this.get(e);const u=typeof t!="function"?t:t(e,...r);return this.set(e,u),u},enumerable:!1,configurable:!0,writable:!0},get1:{value:async function(e,t=null,...r){if(this.has(e))return this.get(e);const u=typeof t!="function"?t:await t(e,...r);return this.set(e,u),u},enumerable:!1,configurable:!0,writable:!0},toObject:{value:function(){return Object.fromEntries(this)},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Set.prototype,{length0:{value:function(){return this.size},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return this.entries()},enumerable:!1,configurable:!0,writable:!0},toArray:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Date,{new:{value:function(...e){return e.length!=1?new Date(...e):Number.isNaN(+e[0])?new Date(e[0].includes("T")?e[0]:e[0].replace(/-/g,"/")):new Date(e[0]>265e7?e[0]:e[0]*1e3)},enumerable:!1,configurable:!0,writable:!0},format:{value:function(e="y-m-d h:i:s"){return new Date().format(e)},enumerable:!1,configurable:!0,writable:!0},unix:{value:function(){return this.now()/1e3|0},enumerable:!1,configurable:!0,writable:!0},fromUnix:{value:function(e=0){return this.new((e||0)*1e3)},enumerable:!1,configurable:!0,writable:!0},expr:{value:function(e={}){return new Date().expr(e)},enumerable:!1,configurable:!0,writable:!0},toDayRange:{value:function(){const e=new Date,t=e.getFullYear(),r=e.getMonth(),u=e.getDate(),n=new Date(t,r,u).getTime()/1e3|0;return[n,n+86400-1]},enumerable:!1,configurable:!0,writable:!0},toWeekRange:{value:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);const t=e.getFullYear(),r=e.getMonth(),u=e.getDate(),n=new Date(t,r,u).getTime()/1e3|0;return[n,n+86400*7-1]},enumerable:!1,configurable:!0,writable:!0},toMonthRange:{value:function(){const e=new Date,t=e.getFullYear(),r=e.getMonth(),u=new Date(t,r,1).getTime()/1e3|0,n=new Date(t,r+1,0,23,59,59).getTime()/1e3|0;return[u,n]},enumerable:!1,configurable:!0,writable:!0},toYearRange:{value:function(){const t=new Date().getFullYear(),r=new Date(t,1,1).getTime()/1e3|0,u=new Date(t+1,1,0,23,59,59).getTime()/1e3|0;return[r,u]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Date.prototype,{format:{value:function(e="y-m-d h:i:s"){if(this.getTime()===0)return"-";const t={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 e.replace(/([ymdhisle])/ig,(r,u)=>u>="A"&&u<="Z"?t[u.toLowerCase()]:t[u].toString().padStart(u==="l"?3:2,"0"))},enumerable:!1,configurable:!0,writable:!0},unix:{value:function(){return this.getTime()/1e3|0},enumerable:!1,configurable:!0,writable:!0},isLeapYear:{value:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},enumerable:!1,configurable:!0,writable:!0},getMonthDay:{value:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},enumerable:!1,configurable:!0,writable:!0},expr:{value:function({y:e=0,m:t=0,d:r=0,h:u=0,i:n=0,s:l=0}){const a=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(a.getDate(),this.getDate())+r,this.getHours()+u,this.getMinutes()+n,this.getSeconds()+l)},enumerable:!1,configurable:!0,writable:!0},begin:{value:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},enumerable:!1,configurable:!0,writable:!0},end:{value:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},enumerable:!1,configurable:!0,writable:!0},week:{value:function(e,t=1){let r=new Date(this.getTime());for(;r.getDay()!==e;)r=new Date(r.getTime()+864e5*t);return r},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return this.getTime()},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(RegExp.prototype,{toJSON:{value:function(){return this.toString()},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Promise.prototype,{tryCatch:{value:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Promise,{channel:{value:function(){let e=null,t=null;return[new this((u,n)=>{e=u,t=n}),e,t]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(JSON,{parse0:{value:function(e,t=null){try{if(typeof e!="string")throw new Error("not string");return JSON.parse(e)}catch{return t}},enumerable:!1,configurable:!0,writable:!0}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esexts",
3
- "version": "1.1.16",
3
+ "version": "1.2.1",
4
4
  "description": "esexts",
5
5
  "author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
6
6
  "homepage": "https://github.com/dotcoo/esexts#readme",