esexts 1.3.0 → 1.3.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 +33 -27
- package/dist/esexts.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/esexts.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const h = Object.defineProperties, n = { enumerable: !1, configurable: !0, writable: !0 };
|
|
2
2
|
function p(t = { array: !1 }) {
|
|
3
3
|
return function(e = {}, ...r) {
|
|
4
4
|
const u = (i, s) => {
|
|
@@ -20,7 +20,7 @@ function p(t = { array: !1 }) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
const b = p({ array: !1 }), d = p({ array: !0 });
|
|
23
|
-
|
|
23
|
+
h(Object, {
|
|
24
24
|
isObject: {
|
|
25
25
|
value: function(t) {
|
|
26
26
|
return Object.prototype.toString.call(t) === "[object Object]";
|
|
@@ -40,7 +40,7 @@ l(Object, {
|
|
|
40
40
|
...n
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
|
|
43
|
+
h(Object.prototype, {
|
|
44
44
|
clone0: {
|
|
45
45
|
value: function() {
|
|
46
46
|
return JSON.parse(JSON.stringify(this));
|
|
@@ -113,6 +113,12 @@ l(Object.prototype, {
|
|
|
113
113
|
},
|
|
114
114
|
...n
|
|
115
115
|
},
|
|
116
|
+
toArray0: {
|
|
117
|
+
value: function() {
|
|
118
|
+
return Array.isArray(this) ? this : [this];
|
|
119
|
+
},
|
|
120
|
+
...n
|
|
121
|
+
},
|
|
116
122
|
log0: {
|
|
117
123
|
value: function(...t) {
|
|
118
124
|
return console.log(...t, this), this;
|
|
@@ -184,7 +190,7 @@ l(Object.prototype, {
|
|
|
184
190
|
...n
|
|
185
191
|
}
|
|
186
192
|
});
|
|
187
|
-
|
|
193
|
+
h(Number.prototype, {
|
|
188
194
|
ceil: {
|
|
189
195
|
value: function() {
|
|
190
196
|
return Math.ceil(this);
|
|
@@ -249,7 +255,7 @@ l(Number.prototype, {
|
|
|
249
255
|
...n
|
|
250
256
|
}
|
|
251
257
|
});
|
|
252
|
-
|
|
258
|
+
h(BigInt.prototype, {
|
|
253
259
|
toJSON: {
|
|
254
260
|
value: function() {
|
|
255
261
|
return this < BigInt(Number.MIN_SAFE_INTEGER) || this > BigInt(Number.MAX_SAFE_INTEGER) ? this.toString() : Number(this);
|
|
@@ -257,7 +263,7 @@ l(BigInt.prototype, {
|
|
|
257
263
|
...n
|
|
258
264
|
}
|
|
259
265
|
});
|
|
260
|
-
|
|
266
|
+
h(String.prototype, {
|
|
261
267
|
length0: {
|
|
262
268
|
value: function() {
|
|
263
269
|
return this.length;
|
|
@@ -424,7 +430,7 @@ l(String.prototype, {
|
|
|
424
430
|
...n
|
|
425
431
|
}
|
|
426
432
|
});
|
|
427
|
-
typeof Iterator < "u" &&
|
|
433
|
+
typeof Iterator < "u" && h(Iterator.prototype, {
|
|
428
434
|
toArray: {
|
|
429
435
|
value: function() {
|
|
430
436
|
return Array.from(this);
|
|
@@ -432,7 +438,7 @@ typeof Iterator < "u" && l(Iterator.prototype, {
|
|
|
432
438
|
...n
|
|
433
439
|
}
|
|
434
440
|
});
|
|
435
|
-
|
|
441
|
+
h(Array.prototype, {
|
|
436
442
|
length0: {
|
|
437
443
|
value: function() {
|
|
438
444
|
return this.length;
|
|
@@ -647,14 +653,14 @@ l(Array.prototype, {
|
|
|
647
653
|
// ====== Tree ======
|
|
648
654
|
toTree: {
|
|
649
655
|
value: function(t = {}) {
|
|
650
|
-
const { id: e = "id", pid: r = "pid", level: u = "level", root: i = "root", parent: s = "parent", children: o = "children", empty: f = null, hasRoot: c = !0 } = t, v = this.toObject((
|
|
651
|
-
|
|
652
|
-
for (const
|
|
653
|
-
l
|
|
656
|
+
const { id: e = "id", pid: r = "pid", level: u = "level", root: i = "root", parent: s = "parent", children: o = "children", empty: f = null, hasRoot: c = !0 } = t, v = this.toObject((l) => [l[e], l]), g = this.toGroup((l) => [l[r], l]), a = this.length && c ? this.find((l) => l[r] === 0) : { [e]: 0, [r]: -1, [i]: null, [s]: null, [o]: g[0] };
|
|
657
|
+
h(a, { [i]: { value: a, enumerable: !1, configurable: !0, writable: !0 } });
|
|
658
|
+
for (const l of this)
|
|
659
|
+
h(l, {
|
|
654
660
|
[i]: { value: a, enumerable: !1, configurable: !0, writable: !0 },
|
|
655
|
-
[s]: { value: v[
|
|
656
|
-
}),
|
|
657
|
-
return a.treeEach0((
|
|
661
|
+
[s]: { value: v[l[r]], enumerable: !1, configurable: !0, writable: !0 }
|
|
662
|
+
}), l[o] = g[l[e]] || f;
|
|
663
|
+
return a.treeEach0((l) => l[u] = l[s] ? l[s][u] + 1 : 0, -1, o), a;
|
|
658
664
|
},
|
|
659
665
|
...n
|
|
660
666
|
},
|
|
@@ -664,7 +670,7 @@ l(Array.prototype, {
|
|
|
664
670
|
const { id: u = "id", pid: i = "pid", level: s = "level", root: o = "root", parent: f = "parent", children: c = "children", empty: v = null } = t;
|
|
665
671
|
e = e || { [u]: 0, [i]: -1, [s]: 0, [o]: null, [f]: null, [c]: this }, r = r || e;
|
|
666
672
|
for (const a of this)
|
|
667
|
-
|
|
673
|
+
h(a, {
|
|
668
674
|
[o]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
|
|
669
675
|
[f]: { value: r, enumerable: !1, configurable: !0, writable: !0 }
|
|
670
676
|
}), a[i] = r[u], a[s] = r[s] + 1, a[c] = a[c] && a[c].length ? a[c] : v, (g = a[c]) == null || g.tree2tree(t, e, a);
|
|
@@ -698,7 +704,7 @@ l(Array.prototype, {
|
|
|
698
704
|
...n
|
|
699
705
|
}
|
|
700
706
|
});
|
|
701
|
-
|
|
707
|
+
h(ArrayBuffer.prototype, {
|
|
702
708
|
toUint8Array: {
|
|
703
709
|
value: function() {
|
|
704
710
|
return new Uint8Array(this);
|
|
@@ -706,7 +712,7 @@ l(ArrayBuffer.prototype, {
|
|
|
706
712
|
...n
|
|
707
713
|
}
|
|
708
714
|
});
|
|
709
|
-
|
|
715
|
+
h(Uint8Array.prototype, {
|
|
710
716
|
bytes2hex: {
|
|
711
717
|
value: Array.prototype.bytes2hex,
|
|
712
718
|
...n
|
|
@@ -726,7 +732,7 @@ l(Uint8Array.prototype, {
|
|
|
726
732
|
...n
|
|
727
733
|
}
|
|
728
734
|
});
|
|
729
|
-
|
|
735
|
+
h(Map.prototype, {
|
|
730
736
|
length0: {
|
|
731
737
|
value: function() {
|
|
732
738
|
return this.size;
|
|
@@ -782,7 +788,7 @@ l(Map.prototype, {
|
|
|
782
788
|
...n
|
|
783
789
|
}
|
|
784
790
|
});
|
|
785
|
-
|
|
791
|
+
h(Set.prototype, {
|
|
786
792
|
length0: {
|
|
787
793
|
value: function() {
|
|
788
794
|
return this.size;
|
|
@@ -808,7 +814,7 @@ l(Set.prototype, {
|
|
|
808
814
|
...n
|
|
809
815
|
}
|
|
810
816
|
});
|
|
811
|
-
|
|
817
|
+
h(Date, {
|
|
812
818
|
new: {
|
|
813
819
|
value: function(...t) {
|
|
814
820
|
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);
|
|
@@ -871,7 +877,7 @@ l(Date, {
|
|
|
871
877
|
...n
|
|
872
878
|
}
|
|
873
879
|
});
|
|
874
|
-
|
|
880
|
+
h(Date.prototype, {
|
|
875
881
|
format: {
|
|
876
882
|
value: function(t = "y-m-d h:i:s") {
|
|
877
883
|
if (this.getTime() === 0)
|
|
@@ -943,7 +949,7 @@ l(Date.prototype, {
|
|
|
943
949
|
...n
|
|
944
950
|
}
|
|
945
951
|
});
|
|
946
|
-
|
|
952
|
+
h(RegExp.prototype, {
|
|
947
953
|
toJSON: {
|
|
948
954
|
value: function() {
|
|
949
955
|
return this.toString();
|
|
@@ -951,7 +957,7 @@ l(RegExp.prototype, {
|
|
|
951
957
|
...n
|
|
952
958
|
}
|
|
953
959
|
});
|
|
954
|
-
|
|
960
|
+
h(Promise.prototype, {
|
|
955
961
|
tryCatch: {
|
|
956
962
|
value: function() {
|
|
957
963
|
return new Promise((t) => this.then((e) => t([e, null])).catch((e) => t([null, e])));
|
|
@@ -959,7 +965,7 @@ l(Promise.prototype, {
|
|
|
959
965
|
...n
|
|
960
966
|
}
|
|
961
967
|
});
|
|
962
|
-
typeof Promise.withResolvers > "u" &&
|
|
968
|
+
typeof Promise.withResolvers > "u" && h(Promise, {
|
|
963
969
|
withResolvers: {
|
|
964
970
|
value: function() {
|
|
965
971
|
let t = null, e = null;
|
|
@@ -970,7 +976,7 @@ typeof Promise.withResolvers > "u" && l(Promise, {
|
|
|
970
976
|
...n
|
|
971
977
|
}
|
|
972
978
|
});
|
|
973
|
-
|
|
979
|
+
h(Promise, {
|
|
974
980
|
channel: {
|
|
975
981
|
value: function() {
|
|
976
982
|
let t = null, e = null;
|
|
@@ -981,7 +987,7 @@ l(Promise, {
|
|
|
981
987
|
...n
|
|
982
988
|
}
|
|
983
989
|
});
|
|
984
|
-
|
|
990
|
+
h(JSON, {
|
|
985
991
|
parse0: {
|
|
986
992
|
value: function(t, e = null) {
|
|
987
993
|
try {
|
package/dist/esexts.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(l){typeof define=="function"&&define.amd?define(l):l()})(function(){"use strict";const l=Object.defineProperties,n={enumerable:!1,configurable:!0,writable:!0};function p(t={array:!1}){return function(e={},...r){const u=(i,s)=>{const o=Object.prototype.toString.call(i),f=Object.prototype.toString.call(s);if(o!==f)return s;if(o==="[object Array]")return t.array?i.concat(...s):s;if(o==="[object Object]"){for(const c in s)i[c]=u(i[c],s[c]);return i}else return s};for(const i of r)e=u(e,i);return e}}const b=p({array:!1}),d=p({array:!0});l(Object,{isObject:{value:function(t){return Object.prototype.toString.call(t)==="[object Object]"},...n},merge0:{value:function(...t){return b(this,...t)},...n},concat0:{value:function(...t){return d(this,...t)},...n}}),l(Object.prototype,{clone0:{value:function(){return JSON.parse(JSON.stringify(this))},...n},length0:{value:function(){return Object.keys(this).length},...n},entries0:{value:function(){return Object.entries(this)},...n},keys0:{value:function(){return Object.keys(this)},...n},values0:{value:function(){return Object.values(this)},...n},merge0:{value:function(...t){return b(this,...t)},...n},concat0:{value:function(...t){return d(this,...t)},...n},map0:{value:function(t=(r,u,i)=>[r,u],e=0){return Object.entries(this).map(([r,u])=>t(r,u,e++))},...n},pick0:{value:function(...t){const e={};for(const r of t)e[r]=this[r];return e},...n},omit0:{value:function(...t){const e={},r=new Set(t);for(const u in this)r.has(u)||(e[u]=this[u]);return e},...n},attr0:{value:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):this[t]},...n},log0:{value:function(...t){return console.log(...t,this),this},...n},debug0:{value:function(...t){return console.debug(...t,this),this},...n},getParents0:{value:function(t=!1,e=-1,r="parent"){const u=t?[this]:[];let i=this[r];for(;i&&e--!=0;)u.push(i),i=i[r];return u},...n},getChildrens0:{value:function(t=!1,e=-1,r="children"){const u=[],i=(s,o,f)=>{if(o&&u.push(s),!(f==0||!s[r]||s[r].length==0))for(const c of s[r])i(c,!0,f-1)};return i(this,t,e),u},...n},treeFind0:{value:function(t,e=!0,r=-1,u="children"){if(e&&t(this))return this;if(r==0||!this[u]||this[u].length==0)return null;for(const i of this[u]){const s=i.treeFind0(t,!0,r-1,u);if(s!==null)return s}return null},...n},treeEach0:{value:function(t,e=!0,r=-1,u="children"){if(e&&t(this),!(r==0||!this[u]||this[u].length==0)){for(const i of this[u])i.treeEach0(t,!0,r-1,u);return this}},...n},treeMap0:{value:function(t,e=!0,r=-1,u="children",i=null){const s=e?t(this):this,o=[];if(r==0||!this[u]||this[u].length==0)return s;for(const f of this[u])o.push(f.treeMap0(t,!0,r-1,u,i));return s[u]=o,s},...n}}),l(Number.prototype,{ceil:{value:function(){return Math.ceil(this)},...n},floor:{value:function(){return Math.floor(this)},...n},round:{value:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},...n},trunc:{value:function(){return Math.trunc(this)},...n},abs:{value:function(){return Math.abs(this)},...n},max:{value:function(...t){return Math.max(this,...t)},...n},min:{value:function(...t){return Math.min(this,...t)},...n},baseConvert:{value:function(t=64){let e="",r=this,u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;r>0;)e=u.at(r%t)+e,r=Math.floor(r/t);return e||"0"},...n},toFixed0:{value:function(...t){return+this.toFixed(...t)},...n},toDate:{value:function(){return Date.new(this)},...n}}),l(BigInt.prototype,{toJSON:{value:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)},...n}}),l(String.prototype,{length0:{value:function(){return this.length},...n},substring0:{value: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)},...n},substr0:{value:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},...n},split0:{value:function(t=",",e=-1){const r=this?this.split(t):[];return e===-1?r:r.push0(r.splice(e-1).join(t))},...n},splitNumber:{value:function(t=","){return this.split0(t).map(e=>+e)},...n},splitSegment:{value:function(t=1){const e=[];for(let r=0;r<this.length;r+=t)e.push(this.substring(r,t));return e},...n},sprintf:{value:function(...t){let[e,...r]=this.split(/%[sd]/);for(let u=0;u<r.length;u++)e+=t[u]+r[u];return e},...n},subOf:{value:function(t,e,r=0,u=0){for(let o=0;o<r&&u!=-1;o++,u++)u=this.indexOf(t,u);let i=this.indexOf(t,u),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},...n},lastSubOf:{value:function(t,e,r=0,u=1/0){for(let o=0;o<r&&u!=-1;o++,u--)u=this.lastIndexOf(t,u);let i=this.lastIndexOf(t,u),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},...n},camel2under:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},...n},under2camel:{value:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},...n},camel2pascal:{value:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},...n},pascal2camel:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},...n},under2kebab:{value:function(){return this.replace(/_/g,"-")},...n},kebab2under:{value:function(){return this.replace(/-/g,"_")},...n},baseConvert:{value:function(t=64){let e=0,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let u=0;u<this.length;u++)e=e*t+r.indexOf(this.at(u));return e},...n},toFixed0:{value:function(...t){return+(+this).toFixed(...t)},...n},toDate:{value:function(){return Date.new(this)},...n},hex2bytes:{value:function(){const t=[];for(let e=0;e<this.length;e+=2)t.push(Number.parseInt(this.substring(e,e+2),16));return t},...n},string2bytes:{value:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const t=[],e=encodeURIComponent(this);for(let r=0;r<e.length;)t.push(e.charAt(r)=="%"?Number.parseInt(e.substring(r+1,r+=3),16):e.charCodeAt(r++));return t},...n},base64decode:{value:function(t){const e=[],r={},u=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let s=0;s<u.length;s++)r[u.charAt(s)]=s;const i=this.charAt(this.length-1)!="="?this.length:this.charAt(this.length-2)!="="?this.length-1:this.length-2;for(let s=3;s<i;s+=4){const o=(r[this.charAt(s-3)]<<18)+(r[this.charAt(s-2)]<<12)+(r[this.charAt(s-1)]<<6)+r[this.charAt(s)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(i%4==3){const s=(r[this.charAt(i-3)]<<18)+(r[this.charAt(i-2)]<<12)+(r[this.charAt(i-1)]<<6);e.push((s&16711680)>>16,(s&65280)>>8)}else if(i%4==2){const s=(r[this.charAt(i-2)]<<18)+(r[this.charAt(i-1)]<<12);e.push((s&16711680)>>16)}return e},...n}}),typeof Iterator<"u"&&l(Iterator.prototype,{toArray:{value:function(){return Array.from(this)},...n}}),l(Array.prototype,{length0:{value:function(){return this.length},...n},entries0:{value:function(){return this.entries()},...n},push0:{value:function(...t){return this.push(...t),this},...n},push1:{value:function(...t){return this.push(...t),t[0]},...n},push3:{value:function(...t){return this.push(...t),t},...n},pop0:{value:function(...t){return this.pop(...t),this},...n},pop1:{value:function(...t){return this.pop(...t),t[0]},...n},pop3:{value:function(...t){return this.pop(...t),t},...n},unshift0:{value:function(...t){return this.unshift(...t),this},...n},unshift1:{value:function(...t){return this.unshift(...t),t[0]},...n},unshift3:{value:function(...t){return this.unshift(...t),t},...n},shift0:{value:function(...t){return this.shift(...t),this},...n},shift1:{value:function(...t){return this.shift(...t),t[0]},...n},shift3:{value:function(...t){return this.shift(...t),t},...n},first0:{value:function(t=null){return this.length?this[0]:t},...n},last0:{value:function(t=null){return this.length?this[this.length-1]:t},...n},find0:{value:function(t,e=null){return this.find(t)??e},...n},equals0:{value:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,r)=>e===t[r]))},...n},unique0:{value:function(t=e=>e){const e=new Set;return this.filter(r=>e.has(t(r))?!1:!!e.add(t(r)))},...n},each0:{value:function(t){return this.forEach(t),this},...n},toObject:{value:function(t=(e,r)=>[r,e]){return Object.fromEntries(this.map(t))},...n},toMap:{value:function(t=(e,r)=>[r,e]){return new Map(this.map(t))},...n},toSet:{value:function(){return new Set(this)},...n},toGroup:{value:function(t=e=>[e.id,e]){const e={};for(const r of this){const[u,i]=t(r);u in e||(e[u]=[]),e[u].push(i)}return e},...n},toMerge:{value:function(t=u=>u.id,e=u=>({...u,children:u.children||[]}),r=(u,i)=>u.children.push(i)){const u=[];for(const i of this)r(u.find(s=>t(s)==t(i))??u.push1(e(i)),i);return u},...n},bytes2hex:{value:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},...n},bytes2string:{value:function(){if(typeof TextDecoder<"u")return new TextDecoder().decode(new Uint8Array(this));let t="";for(let e=0;e<this.length;e++)t+="%"+(this[e]<16?"0":"")+this[e].toString(16);return decodeURIComponent(t)},...n},base64encode:{value:function(t=!1,e=!0){let r="",u=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let i=2;i<this.length;i+=3){const s=(this[i-2]<<16)+(this[i-1]<<8)+this[i];r+=u.charAt((s&16515072)>>18)+u.charAt((s&258048)>>12)+u.charAt((s&4032)>>6)+u.charAt(s&63)}if(this.length%3==2){const i=(this[this.length-2]<<16)+(this[this.length-1]<<8);r+=u.charAt((i&16515072)>>18)+u.charAt((i&258048)>>12)+u.charAt((i&4032)>>6)+(e===!1?"":"=")}else if(this.length%3==1){const i=this[this.length-1]<<16;r+=u.charAt((i&16515072)>>18)+u.charAt((i&258048)>>12)+(e===!1?"":"==")}return r},...n},toUint8Array:{value:function(){return new Uint8Array(this)},...n},assoc:{value:function(t,e,r={}){const u=this.unique0(s=>s[t]),i=u.length==0?{}:typeof r=="function"?r(u):r;return this.each0(s=>s[e]=i[s[t]]??null)},...n},toTree:{value:function(t={}){const{id:e="id",pid:r="pid",level:u="level",root:i="root",parent:s="parent",children:o="children",empty:f=null,hasRoot:c=!0}=t,v=this.toObject(h=>[h[e],h]),g=this.toGroup(h=>[h[r],h]),a=this.length&&c?this.find(h=>h[r]===0):{[e]:0,[r]:-1,[i]:null,[s]:null,[o]:g[0]};l(a,{[i]:{value:a,enumerable:!1,configurable:!0,writable:!0}});for(const h of this)l(h,{[i]:{value:a,enumerable:!1,configurable:!0,writable:!0},[s]:{value:v[h[r]],enumerable:!1,configurable:!0,writable:!0}}),h[o]=g[h[e]]||f;return a.treeEach0(h=>h[u]=h[s]?h[s][u]+1:0,-1,o),a},...n},tree2tree:{value:function(t={},e=null,r=null){var g;const{id:u="id",pid:i="pid",level:s="level",root:o="root",parent:f="parent",children:c="children",empty:v=null}=t;e=e||{[u]:0,[i]:-1,[s]:0,[o]:null,[f]:null,[c]:this},r=r||e;for(const a of this)l(a,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[f]:{value:r,enumerable:!1,configurable:!0,writable:!0}}),a[i]=r[u],a[s]=r[s]+1,a[c]=a[c]&&a[c].length?a[c]:v,(g=a[c])==null||g.tree2tree(t,e,a);return e},...n},treeFind0:{value:function(t,e=!0,r=-1,u="children"){for(const i of this){const s=i.treeFind0(t,e,r,u);if(s!==null)return s}return null},...n},treeEach0:{value:function(t,e=!0,r=-1,u="children"){for(const i of this)i.treeEach0(t,e,r,u);return this},...n},treeMap0:{value:function(t,e=!0,r=-1,u="children",i=null){return this.map(s=>s.treeMap0(t,e,r,u,i))},...n}}),l(ArrayBuffer.prototype,{toUint8Array:{value:function(){return new Uint8Array(this)},...n}}),l(Uint8Array.prototype,{bytes2hex:{value:Array.prototype.bytes2hex,...n},bytes2string:{value:Array.prototype.bytes2string,...n},base64encode:{value:Array.prototype.base64encode,...n},toArray:{value:function(){return new Array(...this)},...n}}),l(Map.prototype,{length0:{value:function(){return this.size},...n},entries0:{value:function(){return[...this.entries()]},...n},keys0:{value:function(){return[...this.keys()]},...n},values0:{value:function(){return[...this.values()]},...n},get0:{value:function(t,e=null,...r){if(this.has(t))return this.get(t);const u=typeof e!="function"?e:e(t,...r);return this.set(t,u),u},...n},get1:{value:async function(t,e=null,...r){if(this.has(t))return this.get(t);const u=typeof e!="function"?e:await e(t,...r);return this.set(t,u),u},...n},toObject:{value:function(){return Object.fromEntries(this)},...n},toJSON:{value:function(){return[...this]},...n}}),l(Set.prototype,{length0:{value:function(){return this.size},...n},entries0:{value:function(){return this.entries()},...n},toArray:{value:function(){return[...this]},...n},toJSON:{value:function(){return[...this]},...n}}),l(Date,{new:{value: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)},...n},format:{value:function(t="y-m-d h:i:s"){return new Date().format(t)},...n},unix:{value:function(){return this.now()/1e3|0},...n},fromUnix:{value:function(t=0){return this.new((t||0)*1e3)},...n},expr:{value:function(t={}){return new Date().expr(t)},...n},toDayRange:{value:function(){const t=new Date,e=t.getFullYear(),r=t.getMonth(),u=t.getDate(),i=new Date(e,r,u).getTime()/1e3|0;return[i,i+86400-1]},...n},toWeekRange:{value:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),r=t.getMonth(),u=t.getDate(),i=new Date(e,r,u).getTime()/1e3|0;return[i,i+86400*7-1]},...n},toMonthRange:{value:function(){const t=new Date,e=t.getFullYear(),r=t.getMonth(),u=new Date(e,r,1).getTime()/1e3|0,i=new Date(e,r+1,0,23,59,59).getTime()/1e3|0;return[u,i]},...n},toYearRange:{value:function(){const e=new Date().getFullYear(),r=new Date(e,1,1).getTime()/1e3|0,u=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[r,u]},...n}}),l(Date.prototype,{format:{value: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,(r,u)=>u>="A"&&u<="Z"?e[u.toLowerCase()]:e[u].toString().padStart(u==="l"?3:2,"0"))},...n},unix:{value:function(){return this.getTime()/1e3|0},...n},isLeapYear:{value:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},...n},getMonthDay:{value:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},...n},expr:{value:function({y:t=0,m:e=0,d:r=0,h:u=0,i=0,s=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())+r,this.getHours()+u,this.getMinutes()+i,this.getSeconds()+s)},...n},begin:{value: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))},...n},end:{value: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))},...n},week:{value:function(t,e=1){let r=new Date(this.getTime());for(;r.getDay()!==t;)r=new Date(r.getTime()+864e5*e);return r},...n},toJSON:{value:function(){return this.getTime()},...n}}),l(RegExp.prototype,{toJSON:{value:function(){return this.toString()},...n}}),l(Promise.prototype,{tryCatch:{value:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))},...n}}),typeof Promise.withResolvers>"u"&&l(Promise,{withResolvers:{value:function(){let t=null,e=null;return{promise:new this((u,i)=>{t=u,e=i}),resolve:t,reject:e}},...n}}),l(Promise,{channel:{value:function(){let t=null,e=null;return[new this((u,i)=>{t=u,e=i}),t,e]},...n}}),l(JSON,{parse0:{value:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}},...n}})});
|
|
1
|
+
(function(h){typeof define=="function"&&define.amd?define(h):h()})(function(){"use strict";const h=Object.defineProperties,n={enumerable:!1,configurable:!0,writable:!0};function p(t={array:!1}){return function(e={},...r){const i=(u,s)=>{const o=Object.prototype.toString.call(u),f=Object.prototype.toString.call(s);if(o!==f)return s;if(o==="[object Array]")return t.array?u.concat(...s):s;if(o==="[object Object]"){for(const c in s)u[c]=i(u[c],s[c]);return u}else return s};for(const u of r)e=i(e,u);return e}}const b=p({array:!1}),d=p({array:!0});h(Object,{isObject:{value:function(t){return Object.prototype.toString.call(t)==="[object Object]"},...n},merge0:{value:function(...t){return b(this,...t)},...n},concat0:{value:function(...t){return d(this,...t)},...n}}),h(Object.prototype,{clone0:{value:function(){return JSON.parse(JSON.stringify(this))},...n},length0:{value:function(){return Object.keys(this).length},...n},entries0:{value:function(){return Object.entries(this)},...n},keys0:{value:function(){return Object.keys(this)},...n},values0:{value:function(){return Object.values(this)},...n},merge0:{value:function(...t){return b(this,...t)},...n},concat0:{value:function(...t){return d(this,...t)},...n},map0:{value:function(t=(r,i,u)=>[r,i],e=0){return Object.entries(this).map(([r,i])=>t(r,i,e++))},...n},pick0:{value:function(...t){const e={};for(const r of t)e[r]=this[r];return e},...n},omit0:{value:function(...t){const e={},r=new Set(t);for(const i in this)r.has(i)||(e[i]=this[i]);return e},...n},attr0:{value:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):this[t]},...n},toArray0:{value:function(){return Array.isArray(this)?this:[this]},...n},log0:{value:function(...t){return console.log(...t,this),this},...n},debug0:{value:function(...t){return console.debug(...t,this),this},...n},getParents0:{value:function(t=!1,e=-1,r="parent"){const i=t?[this]:[];let u=this[r];for(;u&&e--!=0;)i.push(u),u=u[r];return i},...n},getChildrens0:{value:function(t=!1,e=-1,r="children"){const i=[],u=(s,o,f)=>{if(o&&i.push(s),!(f==0||!s[r]||s[r].length==0))for(const c of s[r])u(c,!0,f-1)};return u(this,t,e),i},...n},treeFind0:{value:function(t,e=!0,r=-1,i="children"){if(e&&t(this))return this;if(r==0||!this[i]||this[i].length==0)return null;for(const u of this[i]){const s=u.treeFind0(t,!0,r-1,i);if(s!==null)return s}return null},...n},treeEach0:{value:function(t,e=!0,r=-1,i="children"){if(e&&t(this),!(r==0||!this[i]||this[i].length==0)){for(const u of this[i])u.treeEach0(t,!0,r-1,i);return this}},...n},treeMap0:{value:function(t,e=!0,r=-1,i="children",u=null){const s=e?t(this):this,o=[];if(r==0||!this[i]||this[i].length==0)return s;for(const f of this[i])o.push(f.treeMap0(t,!0,r-1,i,u));return s[i]=o,s},...n}}),h(Number.prototype,{ceil:{value:function(){return Math.ceil(this)},...n},floor:{value:function(){return Math.floor(this)},...n},round:{value:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},...n},trunc:{value:function(){return Math.trunc(this)},...n},abs:{value:function(){return Math.abs(this)},...n},max:{value:function(...t){return Math.max(this,...t)},...n},min:{value:function(...t){return Math.min(this,...t)},...n},baseConvert:{value:function(t=64){let e="",r=this,i="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;r>0;)e=i.at(r%t)+e,r=Math.floor(r/t);return e||"0"},...n},toFixed0:{value:function(...t){return+this.toFixed(...t)},...n},toDate:{value:function(){return Date.new(this)},...n}}),h(BigInt.prototype,{toJSON:{value:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)},...n}}),h(String.prototype,{length0:{value:function(){return this.length},...n},substring0:{value: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)},...n},substr0:{value:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},...n},split0:{value:function(t=",",e=-1){const r=this?this.split(t):[];return e===-1?r:r.push0(r.splice(e-1).join(t))},...n},splitNumber:{value:function(t=","){return this.split0(t).map(e=>+e)},...n},splitSegment:{value:function(t=1){const e=[];for(let r=0;r<this.length;r+=t)e.push(this.substring(r,t));return e},...n},sprintf:{value:function(...t){let[e,...r]=this.split(/%[sd]/);for(let i=0;i<r.length;i++)e+=t[i]+r[i];return e},...n},subOf:{value:function(t,e,r=0,i=0){for(let o=0;o<r&&i!=-1;o++,i++)i=this.indexOf(t,i);let u=this.indexOf(t,i),s=this.indexOf(e,u);return u==-1||s==-1?"":(u+=t.length,this.substring(u,s))},...n},lastSubOf:{value:function(t,e,r=0,i=1/0){for(let o=0;o<r&&i!=-1;o++,i--)i=this.lastIndexOf(t,i);let u=this.lastIndexOf(t,i),s=this.indexOf(e,u);return u==-1||s==-1?"":(u+=t.length,this.substring(u,s))},...n},camel2under:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},...n},under2camel:{value:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},...n},camel2pascal:{value:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},...n},pascal2camel:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},...n},under2kebab:{value:function(){return this.replace(/_/g,"-")},...n},kebab2under:{value:function(){return this.replace(/-/g,"_")},...n},baseConvert:{value:function(t=64){let e=0,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let i=0;i<this.length;i++)e=e*t+r.indexOf(this.at(i));return e},...n},toFixed0:{value:function(...t){return+(+this).toFixed(...t)},...n},toDate:{value:function(){return Date.new(this)},...n},hex2bytes:{value:function(){const t=[];for(let e=0;e<this.length;e+=2)t.push(Number.parseInt(this.substring(e,e+2),16));return t},...n},string2bytes:{value:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const t=[],e=encodeURIComponent(this);for(let r=0;r<e.length;)t.push(e.charAt(r)=="%"?Number.parseInt(e.substring(r+1,r+=3),16):e.charCodeAt(r++));return t},...n},base64decode:{value:function(t){const e=[],r={},i=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let s=0;s<i.length;s++)r[i.charAt(s)]=s;const u=this.charAt(this.length-1)!="="?this.length:this.charAt(this.length-2)!="="?this.length-1:this.length-2;for(let s=3;s<u;s+=4){const o=(r[this.charAt(s-3)]<<18)+(r[this.charAt(s-2)]<<12)+(r[this.charAt(s-1)]<<6)+r[this.charAt(s)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(u%4==3){const s=(r[this.charAt(u-3)]<<18)+(r[this.charAt(u-2)]<<12)+(r[this.charAt(u-1)]<<6);e.push((s&16711680)>>16,(s&65280)>>8)}else if(u%4==2){const s=(r[this.charAt(u-2)]<<18)+(r[this.charAt(u-1)]<<12);e.push((s&16711680)>>16)}return e},...n}}),typeof Iterator<"u"&&h(Iterator.prototype,{toArray:{value:function(){return Array.from(this)},...n}}),h(Array.prototype,{length0:{value:function(){return this.length},...n},entries0:{value:function(){return this.entries()},...n},push0:{value:function(...t){return this.push(...t),this},...n},push1:{value:function(...t){return this.push(...t),t[0]},...n},push3:{value:function(...t){return this.push(...t),t},...n},pop0:{value:function(...t){return this.pop(...t),this},...n},pop1:{value:function(...t){return this.pop(...t),t[0]},...n},pop3:{value:function(...t){return this.pop(...t),t},...n},unshift0:{value:function(...t){return this.unshift(...t),this},...n},unshift1:{value:function(...t){return this.unshift(...t),t[0]},...n},unshift3:{value:function(...t){return this.unshift(...t),t},...n},shift0:{value:function(...t){return this.shift(...t),this},...n},shift1:{value:function(...t){return this.shift(...t),t[0]},...n},shift3:{value:function(...t){return this.shift(...t),t},...n},first0:{value:function(t=null){return this.length?this[0]:t},...n},last0:{value:function(t=null){return this.length?this[this.length-1]:t},...n},find0:{value:function(t,e=null){return this.find(t)??e},...n},equals0:{value:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,r)=>e===t[r]))},...n},unique0:{value:function(t=e=>e){const e=new Set;return this.filter(r=>e.has(t(r))?!1:!!e.add(t(r)))},...n},each0:{value:function(t){return this.forEach(t),this},...n},toObject:{value:function(t=(e,r)=>[r,e]){return Object.fromEntries(this.map(t))},...n},toMap:{value:function(t=(e,r)=>[r,e]){return new Map(this.map(t))},...n},toSet:{value:function(){return new Set(this)},...n},toGroup:{value:function(t=e=>[e.id,e]){const e={};for(const r of this){const[i,u]=t(r);i in e||(e[i]=[]),e[i].push(u)}return e},...n},toMerge:{value:function(t=i=>i.id,e=i=>({...i,children:i.children||[]}),r=(i,u)=>i.children.push(u)){const i=[];for(const u of this)r(i.find(s=>t(s)==t(u))??i.push1(e(u)),u);return i},...n},bytes2hex:{value:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},...n},bytes2string:{value:function(){if(typeof TextDecoder<"u")return new TextDecoder().decode(new Uint8Array(this));let t="";for(let e=0;e<this.length;e++)t+="%"+(this[e]<16?"0":"")+this[e].toString(16);return decodeURIComponent(t)},...n},base64encode:{value:function(t=!1,e=!0){let r="",i=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let u=2;u<this.length;u+=3){const s=(this[u-2]<<16)+(this[u-1]<<8)+this[u];r+=i.charAt((s&16515072)>>18)+i.charAt((s&258048)>>12)+i.charAt((s&4032)>>6)+i.charAt(s&63)}if(this.length%3==2){const u=(this[this.length-2]<<16)+(this[this.length-1]<<8);r+=i.charAt((u&16515072)>>18)+i.charAt((u&258048)>>12)+i.charAt((u&4032)>>6)+(e===!1?"":"=")}else if(this.length%3==1){const u=this[this.length-1]<<16;r+=i.charAt((u&16515072)>>18)+i.charAt((u&258048)>>12)+(e===!1?"":"==")}return r},...n},toUint8Array:{value:function(){return new Uint8Array(this)},...n},assoc:{value:function(t,e,r={}){const i=this.unique0(s=>s[t]),u=i.length==0?{}:typeof r=="function"?r(i):r;return this.each0(s=>s[e]=u[s[t]]??null)},...n},toTree:{value:function(t={}){const{id:e="id",pid:r="pid",level:i="level",root:u="root",parent:s="parent",children:o="children",empty:f=null,hasRoot:c=!0}=t,v=this.toObject(l=>[l[e],l]),g=this.toGroup(l=>[l[r],l]),a=this.length&&c?this.find(l=>l[r]===0):{[e]:0,[r]:-1,[u]:null,[s]:null,[o]:g[0]};h(a,{[u]:{value:a,enumerable:!1,configurable:!0,writable:!0}});for(const l of this)h(l,{[u]:{value:a,enumerable:!1,configurable:!0,writable:!0},[s]:{value:v[l[r]],enumerable:!1,configurable:!0,writable:!0}}),l[o]=g[l[e]]||f;return a.treeEach0(l=>l[i]=l[s]?l[s][i]+1:0,-1,o),a},...n},tree2tree:{value:function(t={},e=null,r=null){var g;const{id:i="id",pid:u="pid",level:s="level",root:o="root",parent:f="parent",children:c="children",empty:v=null}=t;e=e||{[i]:0,[u]:-1,[s]:0,[o]:null,[f]:null,[c]:this},r=r||e;for(const a of this)h(a,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[f]:{value:r,enumerable:!1,configurable:!0,writable:!0}}),a[u]=r[i],a[s]=r[s]+1,a[c]=a[c]&&a[c].length?a[c]:v,(g=a[c])==null||g.tree2tree(t,e,a);return e},...n},treeFind0:{value:function(t,e=!0,r=-1,i="children"){for(const u of this){const s=u.treeFind0(t,e,r,i);if(s!==null)return s}return null},...n},treeEach0:{value:function(t,e=!0,r=-1,i="children"){for(const u of this)u.treeEach0(t,e,r,i);return this},...n},treeMap0:{value:function(t,e=!0,r=-1,i="children",u=null){return this.map(s=>s.treeMap0(t,e,r,i,u))},...n}}),h(ArrayBuffer.prototype,{toUint8Array:{value:function(){return new Uint8Array(this)},...n}}),h(Uint8Array.prototype,{bytes2hex:{value:Array.prototype.bytes2hex,...n},bytes2string:{value:Array.prototype.bytes2string,...n},base64encode:{value:Array.prototype.base64encode,...n},toArray:{value:function(){return new Array(...this)},...n}}),h(Map.prototype,{length0:{value:function(){return this.size},...n},entries0:{value:function(){return[...this.entries()]},...n},keys0:{value:function(){return[...this.keys()]},...n},values0:{value:function(){return[...this.values()]},...n},get0:{value:function(t,e=null,...r){if(this.has(t))return this.get(t);const i=typeof e!="function"?e:e(t,...r);return this.set(t,i),i},...n},get1:{value:async function(t,e=null,...r){if(this.has(t))return this.get(t);const i=typeof e!="function"?e:await e(t,...r);return this.set(t,i),i},...n},toObject:{value:function(){return Object.fromEntries(this)},...n},toJSON:{value:function(){return[...this]},...n}}),h(Set.prototype,{length0:{value:function(){return this.size},...n},entries0:{value:function(){return this.entries()},...n},toArray:{value:function(){return[...this]},...n},toJSON:{value:function(){return[...this]},...n}}),h(Date,{new:{value: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)},...n},format:{value:function(t="y-m-d h:i:s"){return new Date().format(t)},...n},unix:{value:function(){return this.now()/1e3|0},...n},fromUnix:{value:function(t=0){return this.new((t||0)*1e3)},...n},expr:{value:function(t={}){return new Date().expr(t)},...n},toDayRange:{value:function(){const t=new Date,e=t.getFullYear(),r=t.getMonth(),i=t.getDate(),u=new Date(e,r,i).getTime()/1e3|0;return[u,u+86400-1]},...n},toWeekRange:{value:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),r=t.getMonth(),i=t.getDate(),u=new Date(e,r,i).getTime()/1e3|0;return[u,u+86400*7-1]},...n},toMonthRange:{value:function(){const t=new Date,e=t.getFullYear(),r=t.getMonth(),i=new Date(e,r,1).getTime()/1e3|0,u=new Date(e,r+1,0,23,59,59).getTime()/1e3|0;return[i,u]},...n},toYearRange:{value:function(){const e=new Date().getFullYear(),r=new Date(e,1,1).getTime()/1e3|0,i=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[r,i]},...n}}),h(Date.prototype,{format:{value: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,(r,i)=>i>="A"&&i<="Z"?e[i.toLowerCase()]:e[i].toString().padStart(i==="l"?3:2,"0"))},...n},unix:{value:function(){return this.getTime()/1e3|0},...n},isLeapYear:{value:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},...n},getMonthDay:{value:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},...n},expr:{value:function({y:t=0,m:e=0,d:r=0,h:i=0,i:u=0,s=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())+r,this.getHours()+i,this.getMinutes()+u,this.getSeconds()+s)},...n},begin:{value: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))},...n},end:{value: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))},...n},week:{value:function(t,e=1){let r=new Date(this.getTime());for(;r.getDay()!==t;)r=new Date(r.getTime()+864e5*e);return r},...n},toJSON:{value:function(){return this.getTime()},...n}}),h(RegExp.prototype,{toJSON:{value:function(){return this.toString()},...n}}),h(Promise.prototype,{tryCatch:{value:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))},...n}}),typeof Promise.withResolvers>"u"&&h(Promise,{withResolvers:{value:function(){let t=null,e=null;return{promise:new this((i,u)=>{t=i,e=u}),resolve:t,reject:e}},...n}}),h(Promise,{channel:{value:function(){let t=null,e=null;return[new this((i,u)=>{t=i,e=u}),t,e]},...n}}),h(JSON,{parse0:{value:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}},...n}})});
|