esexts 1.3.3 → 1.3.4
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 +25 -12
- package/dist/esexts.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/esexts.js
CHANGED
|
@@ -35,7 +35,7 @@ function x(...t) {
|
|
|
35
35
|
}
|
|
36
36
|
return e;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function m(...t) {
|
|
39
39
|
const e = {};
|
|
40
40
|
for (const n of t) {
|
|
41
41
|
const [r, i] = Array.isArray(n) ? n : [n, n];
|
|
@@ -61,7 +61,7 @@ function d(...t) {
|
|
|
61
61
|
}
|
|
62
62
|
return e;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function b(...t) {
|
|
65
65
|
const e = {};
|
|
66
66
|
for (const n of t) {
|
|
67
67
|
const [r, i] = Array.isArray(n) ? n : [n, n];
|
|
@@ -85,7 +85,7 @@ function O(t, ...e) {
|
|
|
85
85
|
}
|
|
86
86
|
return n;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function A(t, ...e) {
|
|
89
89
|
const n = {};
|
|
90
90
|
for (const r of e) {
|
|
91
91
|
const [i, u] = Array.isArray(r) ? r : [r, r];
|
|
@@ -98,6 +98,19 @@ function m(t, ...e) {
|
|
|
98
98
|
}
|
|
99
99
|
return n;
|
|
100
100
|
}
|
|
101
|
+
function M(t, ...e) {
|
|
102
|
+
const n = {};
|
|
103
|
+
for (const r of e) {
|
|
104
|
+
const [i, u] = Array.isArray(r) ? r : [r, r];
|
|
105
|
+
n[u] = {
|
|
106
|
+
value: function(...o) {
|
|
107
|
+
return t[i](this, ...o), this;
|
|
108
|
+
},
|
|
109
|
+
...s
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return n;
|
|
113
|
+
}
|
|
101
114
|
function w(t = { array: !1 }) {
|
|
102
115
|
return function(e = {}, ...n) {
|
|
103
116
|
const r = (i, u) => {
|
|
@@ -152,7 +165,7 @@ l(Object.prototype, {
|
|
|
152
165
|
},
|
|
153
166
|
...s
|
|
154
167
|
},
|
|
155
|
-
...
|
|
168
|
+
...A(Object, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
156
169
|
merge0: {
|
|
157
170
|
value: function(...t) {
|
|
158
171
|
return D(this, ...t);
|
|
@@ -201,7 +214,7 @@ l(Object.prototype, {
|
|
|
201
214
|
},
|
|
202
215
|
...s
|
|
203
216
|
},
|
|
204
|
-
...
|
|
217
|
+
...M(console, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
|
|
205
218
|
// ====== Tree ======
|
|
206
219
|
getParents0: {
|
|
207
220
|
value: function(t = !1, e = -1, n = "parent") {
|
|
@@ -262,7 +275,7 @@ l(Object.prototype, {
|
|
|
262
275
|
}
|
|
263
276
|
});
|
|
264
277
|
l(Number.prototype, {
|
|
265
|
-
...
|
|
278
|
+
...A(Math, "ceil", "floor", "trunc", "abs", "max", "min"),
|
|
266
279
|
baseConvert: {
|
|
267
280
|
value: function(t = 64) {
|
|
268
281
|
let e = "", n = this, r = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
|
|
@@ -474,10 +487,10 @@ l(Array, {
|
|
|
474
487
|
});
|
|
475
488
|
l(Array.prototype, {
|
|
476
489
|
...d(["length", "length0"]),
|
|
477
|
-
...
|
|
490
|
+
...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
478
491
|
...v(["push", "push0"], ["pop", "pop0"], ["shift", "shift0"], ["unshift", "unshift0"]),
|
|
479
492
|
...x(["push", "push1"], ["unshift", "unshift1"]),
|
|
480
|
-
...
|
|
493
|
+
...m(["push", "push3"], ["unshift", "unshift3"]),
|
|
481
494
|
first0: {
|
|
482
495
|
value: function(t = null) {
|
|
483
496
|
return this.length ? this[0] : t;
|
|
@@ -676,9 +689,9 @@ l(Map, {
|
|
|
676
689
|
});
|
|
677
690
|
l(Map.prototype, {
|
|
678
691
|
...d(["size", "length0"]),
|
|
679
|
-
...
|
|
692
|
+
...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
680
693
|
...v(["set", "set0"], ["delete", "delete0"]),
|
|
681
|
-
...
|
|
694
|
+
...m(["set", "set3"]),
|
|
682
695
|
get0: {
|
|
683
696
|
value: function(t, e = null) {
|
|
684
697
|
return this.has(t) ? this.get(t) : e;
|
|
@@ -721,9 +734,9 @@ l(Set, {
|
|
|
721
734
|
});
|
|
722
735
|
l(Set.prototype, {
|
|
723
736
|
...d(["size", "length0"]),
|
|
724
|
-
...
|
|
737
|
+
...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
|
|
725
738
|
...v(["add", "add0"], ["delete", "delete0"]),
|
|
726
|
-
...
|
|
739
|
+
...m(["add", "add3"]),
|
|
727
740
|
toArray: {
|
|
728
741
|
value: function() {
|
|
729
742
|
return [...this];
|
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,u={enumerable:!1,configurable:!0,writable:!0};function v(){return{new:{value:function(...t){return new this(...t)},...u}}}function p(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(...s){return this[r](...s),this},...u}}return e}function x(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(...s){return this[r](...s),s[0]},...u}}return e}function y(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(...s){return this[r](...s),s},...u}}return e}function d(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(){return this[r]},...u}}return e}function m(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(...s){return[...this[r](...s)]},...u}}return e}function O(t,...e){const n={};for(const r of e){const[i,s]=Array.isArray(r)?r:[r,r];n[s]={value:t[i],...u}}return n}function b(t,...e){const n={};for(const r of e){const[i,s]=Array.isArray(r)?r:[r,r];n[s]={value:function(...o){return t[i](this,...o)},...u}}return n}function w(t={array:!1}){return function(e={},...n){const r=(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]=r(i[c],s[c]);return i}else return s};for(const i of n)e=r(e,i);return e}}const D=w({array:!1}),F=w({array:!0});l(Object,{isObject:{value:function(t){return Object.prototype.toString.call(t)==="[object Object]"},...u},merge0:{value:function(...t){return D(this,...t)},...u},concat0:{value:function(...t){return F(this,...t)},...u}}),l(Object.prototype,{clone0:{value:function(){return JSON.parse(JSON.stringify(this))},...u},length0:{value:function(){return Object.keys(this).length},...u},...b(Object,["entries","entries0"],["keys","keys0"],["values","values0"]),merge0:{value:function(...t){return D(this,...t)},...u},concat0:{value:function(...t){return F(this,...t)},...u},map0:{value:function(t=(n,r,i)=>[n,r],e=0){return Object.entries(this).map(([n,r])=>t(n,r,e++))},...u},pick0:{value:function(...t){const e={};for(const n of t)e[n]=this[n];return e},...u},omit0:{value:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},...u},attr0:{value:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):this[t]},...u},toArray0:{value:function(){return Array.isArray(this)?this:[this]},...u},...b(console,["debug","debug0"],["log","log0"],["info","info0"],["warn","warn0"],["error","error0"],["dir","dir0"]),getParents0:{value: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},...u},getChildrens0:{value:function(t=!1,e=-1,n="children"){const r=[],i=(s,o,f)=>{if(o&&r.push(s),!(f==0||!s[n]||s[n].length==0))for(const c of s[n])i(c,!0,f-1)};return i(this,t,e),r},...u},treeFind0:{value: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 s=i.treeFind0(t,!0,n-1,r);if(s!==null)return s}return null},...u},treeEach0:{value: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}},...u},treeMap0:{value:function(t,e=!0,n=-1,r="children",i=null){const s=e?t(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return s;for(const f of this[r])o.push(f.treeMap0(t,!0,n-1,r,i));return s[r]=o,s},...u}}),l(Number.prototype,{...b(Math,"ceil","floor","trunc","abs","max","min"),baseConvert:{value: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"},...u},round:{value:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},...u},toFixed0:{value:function(...t){return+this.toFixed(...t)},...u},toDate:{value:function(){return Date.new(this)},...u}}),l(BigInt.prototype,{toJSON:{value:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)},...u}}),l(String.prototype,{...d(["length","length0"]),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)},...u},substr0:{value:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},...u},split0:{value:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.push0(n.splice(e-1).join(t))},...u},splitNumber:{value:function(t=","){return this.split0(t).map(e=>+e)},...u},splitSegment:{value:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},...u},sprintf:{value:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},...u},subOf:{value: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),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},...u},lastSubOf:{value: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),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},...u},camel2under:{value:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},...u},under2camel:{value:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},...u},camel2pascal:{value:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},...u},pascal2camel:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},...u},under2kebab:{value:function(){return this.replace(/_/g,"-")},...u},kebab2under:{value:function(){return this.replace(/-/g,"_")},...u},baseConvert:{value: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},...u},toFixed0:{value:function(...t){return+(+this).toFixed(...t)},...u},toDate:{value:function(){return Date.new(this)},...u},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},...u},string2bytes:{value:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const t=[],e=encodeURIComponent(this);for(let n=0;n<e.length;)t.push(e.charAt(n)=="%"?Number.parseInt(e.substring(n+1,n+=3),16):e.charCodeAt(n++));return t},...u},base64decode:{value:function(t){const e=[],n={},r=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let s=0;s<r.length;s++)n[r.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=(n[this.charAt(s-3)]<<18)+(n[this.charAt(s-2)]<<12)+(n[this.charAt(s-1)]<<6)+n[this.charAt(s)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(i%4==3){const s=(n[this.charAt(i-3)]<<18)+(n[this.charAt(i-2)]<<12)+(n[this.charAt(i-1)]<<6);e.push((s&16711680)>>16,(s&65280)>>8)}else if(i%4==2){const s=(n[this.charAt(i-2)]<<18)+(n[this.charAt(i-1)]<<12);e.push((s&16711680)>>16)}return e},...u}}),typeof Iterator<"u"&&l(Iterator.prototype,{toArray:{value:function(){return Array.from(this)},...u}}),l(Array,{...v()}),l(Array.prototype,{...d(["length","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...p(["push","push0"],["pop","pop0"],["shift","shift0"],["unshift","unshift0"]),...x(["push","push1"],["unshift","unshift1"]),...y(["push","push3"],["unshift","unshift3"]),first0:{value:function(t=null){return this.length?this[0]:t},...u},last0:{value:function(t=null){return this.length?this[this.length-1]:t},...u},find0:{value:function(t,e=null){return this.find(t)??e},...u},equals0:{value:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},...u},unique0:{value:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...u},...p(["forEach","each0"]),toObject:{value:function(t=(e,n)=>[n,e]){return Object.fromEntries(this.map(t))},...u},toMap:{value:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},...u},toSet:{value:function(t=e=>e){return new Set(this.map(t))},...u},toGroup:{value:function(t=e=>[e.id,e]){const e={};for(const n of this){const[r,i]=t(n);r in e||(e[r]=[]),e[r].push(i)}return e},...u},toMerge:{value:function(t=r=>r.id,e=r=>({...r,children:[]}),n=(r,i)=>r.children.push(i)){const r=[];for(const i of this)n(r.find(s=>t(s)==t(i))??r.push1(e(i)),i);return r},...u},bytes2hex:{value:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},...u},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)},...u},base64encode:{value:function(t=!1,e=!0){let n="",r=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];n+=r.charAt((s&16515072)>>18)+r.charAt((s&258048)>>12)+r.charAt((s&4032)>>6)+r.charAt(s&63)}if(this.length%3==2){const i=(this[this.length-2]<<16)+(this[this.length-1]<<8);n+=r.charAt((i&16515072)>>18)+r.charAt((i&258048)>>12)+r.charAt((i&4032)>>6)+(e===!1?"":"=")}else if(this.length%3==1){const i=this[this.length-1]<<16;n+=r.charAt((i&16515072)>>18)+r.charAt((i&258048)>>12)+(e===!1?"":"==")}return n},...u},toUint8Array:{value:function(){return new Uint8Array(this)},...u},assoc:{value:function(t,e,n={}){const r=this.unique0(s=>s[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each0(s=>s[e]=i[s[t]]??null)},...u},toTree:{value:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:s="parent",children:o="children",empty:f=null,hasRoot:c=!0}=t,A=this.toObject(a=>[a[e],a]),g=this.toGroup(a=>[a[n],a]),h=this.length&&c?this.find(a=>a[n]===0):{[e]:0,[n]:-1,[i]:null,[s]:null,[o]:g[0]};l(h,{[i]:{value:h,enumerable:!1,configurable:!0,writable:!0}});for(const a of this)l(a,{[i]:{value:h,enumerable:!1,configurable:!0,writable:!0},[s]:{value:A[a[n]],enumerable:!1,configurable:!0,writable:!0}}),a[o]=g[a[e]]||f;return h.treeEach0(a=>a[r]=a[s]?a[s][r]+1:0,-1,o),h},...u},tree2tree:{value:function(t={},e=null,n=null){var g;const{id:r="id",pid:i="pid",level:s="level",root:o="root",parent:f="parent",children:c="children",empty:A=null}=t;e=e||{[r]:0,[i]:-1,[s]:0,[o]:null,[f]:null,[c]:this},n=n||e;for(const h of this)l(h,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[f]:{value:n,enumerable:!1,configurable:!0,writable:!0}}),h[i]=n[r],h[s]=n[s]+1,h[c]=h[c]&&h[c].length?h[c]:A,(g=h[c])==null||g.tree2tree(t,e,h);return e},...u},treeFind0:{value:function(t,e=!0,n=-1,r="children"){for(const i of this){const s=i.treeFind0(t,e,n,r);if(s!==null)return s}return null},...u},treeEach0:{value:function(t,e=!0,n=-1,r="children"){for(const i of this)i.treeEach0(t,e,n,r);return this},...u},treeMap0:{value:function(t,e=!0,n=-1,r="children",i=null){return this.map(s=>s.treeMap0(t,e,n,r,i))},...u}}),l(ArrayBuffer.prototype,{toUint8Array:{value:function(){return new Uint8Array(this)},...u}}),l(Uint8Array.prototype,{...O(Array.prototype,"bytes2hex","bytes2string","base64encode"),toArray:{value:function(){return new Array(...this)},...u}}),l(Map,{...v()}),l(Map.prototype,{...d(["size","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...p(["set","set0"],["delete","delete0"]),...y(["set","set3"]),get0:{value:function(t,e=null){return this.has(t)?this.get(t):e},...u},get1:{value:function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,e(t,...n))[1]},...u},getAsync1:{value:async function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,await e(t,...n))[1]},...u},toObject:{value:function(){return Object.fromEntries(this)},...u},toArray:{value:function(){return[...this]},...u},toJSON:{value:function(){return[...this]},...u}}),l(Set,{...v()}),l(Set.prototype,{...d(["size","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...p(["add","add0"],["delete","delete0"]),...y(["add","add3"]),toArray:{value:function(){return[...this]},...u},toJSON:{value:function(){return[...this]},...u}}),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)},...u},format:{value:function(t="y-m-d h:i:s"){return new Date().format(t)},...u},unix:{value:function(){return this.now()/1e3|0},...u},fromUnix:{value:function(t=0){return new Date((t||0)*1e3)},...u},expr:{value:function(t={}){return new Date().expr(t)},...u},toDayRange:{value: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]},...u},toWeekRange:{value: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]},...u},toMonthRange:{value: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]},...u},toYearRange:{value: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]},...u}}),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,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="l"?3:2,"0"))},...u},unix:{value:function(){return this.getTime()/1e3|0},...u},isLeapYear:{value:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},...u},getMonthDay:{value:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},...u},expr:{value:function({y:t=0,m:e=0,d:n=0,h:r=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())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+s)},...u},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))},...u},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))},...u},week:{value:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},...u},toJSON:{value:function(){return this.getTime()},...u}}),l(RegExp,{...v()}),l(RegExp.prototype,{toJSON:{value:function(){return this.toString()},...u}}),typeof Promise.withResolvers>"u"&&l(Promise,{withResolvers:{value:function(){let t=null,e=null;return{promise:new this((r,i)=>{t=r,e=i}),resolve:t,reject:e}},...u}}),l(Promise,{channel:{value:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]},...u}}),l(Promise.prototype,{tryCatch:{value:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))},...u}}),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}},...u}})});
|
|
1
|
+
(function(l){typeof define=="function"&&define.amd?define(l):l()})(function(){"use strict";const l=Object.defineProperties,s={enumerable:!1,configurable:!0,writable:!0};function v(){return{new:{value:function(...t){return new this(...t)},...s}}}function p(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(...u){return this[r](...u),this},...s}}return e}function x(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(...u){return this[r](...u),u[0]},...s}}return e}function y(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(...u){return this[r](...u),u},...s}}return e}function d(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(){return this[r]},...s}}return e}function m(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]={value:function(...u){return[...this[r](...u)]},...s}}return e}function O(t,...e){const n={};for(const r of e){const[i,u]=Array.isArray(r)?r:[r,r];n[u]={value:t[i],...s}}return n}function A(t,...e){const n={};for(const r of e){const[i,u]=Array.isArray(r)?r:[r,r];n[u]={value:function(...o){return t[i](this,...o)},...s}}return n}function M(t,...e){const n={};for(const r of e){const[i,u]=Array.isArray(r)?r:[r,r];n[u]={value:function(...o){return t[i](this,...o),this},...s}}return n}function w(t={array:!1}){return function(e={},...n){const r=(i,u)=>{const o=Object.prototype.toString.call(i),f=Object.prototype.toString.call(u);if(o!==f)return u;if(o==="[object Array]")return t.array?i.concat(...u):u;if(o==="[object Object]"){for(const c in u)i[c]=r(i[c],u[c]);return i}else return u};for(const i of n)e=r(e,i);return e}}const D=w({array:!1}),F=w({array:!0});l(Object,{isObject:{value:function(t){return Object.prototype.toString.call(t)==="[object Object]"},...s},merge0:{value:function(...t){return D(this,...t)},...s},concat0:{value:function(...t){return F(this,...t)},...s}}),l(Object.prototype,{clone0:{value:function(){return JSON.parse(JSON.stringify(this))},...s},length0:{value:function(){return Object.keys(this).length},...s},...A(Object,["entries","entries0"],["keys","keys0"],["values","values0"]),merge0:{value:function(...t){return D(this,...t)},...s},concat0:{value:function(...t){return F(this,...t)},...s},map0:{value:function(t=(n,r,i)=>[n,r],e=0){return Object.entries(this).map(([n,r])=>t(n,r,e++))},...s},pick0:{value:function(...t){const e={};for(const n of t)e[n]=this[n];return e},...s},omit0:{value:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},...s},attr0:{value:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):this[t]},...s},toArray0:{value:function(){return Array.isArray(this)?this:[this]},...s},...M(console,["debug","debug0"],["log","log0"],["info","info0"],["warn","warn0"],["error","error0"],["dir","dir0"]),getParents0:{value: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},...s},getChildrens0:{value:function(t=!1,e=-1,n="children"){const r=[],i=(u,o,f)=>{if(o&&r.push(u),!(f==0||!u[n]||u[n].length==0))for(const c of u[n])i(c,!0,f-1)};return i(this,t,e),r},...s},treeFind0:{value: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},...s},treeEach0:{value: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}},...s},treeMap0:{value: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 f of this[r])o.push(f.treeMap0(t,!0,n-1,r,i));return u[r]=o,u},...s}}),l(Number.prototype,{...A(Math,"ceil","floor","trunc","abs","max","min"),baseConvert:{value: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"},...s},round:{value:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},...s},toFixed0:{value:function(...t){return+this.toFixed(...t)},...s},toDate:{value:function(){return Date.new(this)},...s}}),l(BigInt.prototype,{toJSON:{value:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)},...s}}),l(String.prototype,{...d(["length","length0"]),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)},...s},substr0:{value:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},...s},split0:{value:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.push0(n.splice(e-1).join(t))},...s},splitNumber:{value:function(t=","){return this.split0(t).map(e=>+e)},...s},splitSegment:{value:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},...s},sprintf:{value:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},...s},subOf:{value: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))},...s},lastSubOf:{value: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))},...s},camel2under:{value:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},...s},under2camel:{value:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},...s},camel2pascal:{value:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},...s},pascal2camel:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},...s},under2kebab:{value:function(){return this.replace(/_/g,"-")},...s},kebab2under:{value:function(){return this.replace(/-/g,"_")},...s},baseConvert:{value: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},...s},toFixed0:{value:function(...t){return+(+this).toFixed(...t)},...s},toDate:{value:function(){return Date.new(this)},...s},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},...s},string2bytes:{value:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const t=[],e=encodeURIComponent(this);for(let n=0;n<e.length;)t.push(e.charAt(n)=="%"?Number.parseInt(e.substring(n+1,n+=3),16):e.charCodeAt(n++));return t},...s},base64decode:{value:function(t){const e=[],n={},r=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let u=0;u<r.length;u++)n[r.charAt(u)]=u;const i=this.charAt(this.length-1)!="="?this.length:this.charAt(this.length-2)!="="?this.length-1:this.length-2;for(let u=3;u<i;u+=4){const o=(n[this.charAt(u-3)]<<18)+(n[this.charAt(u-2)]<<12)+(n[this.charAt(u-1)]<<6)+n[this.charAt(u)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(i%4==3){const u=(n[this.charAt(i-3)]<<18)+(n[this.charAt(i-2)]<<12)+(n[this.charAt(i-1)]<<6);e.push((u&16711680)>>16,(u&65280)>>8)}else if(i%4==2){const u=(n[this.charAt(i-2)]<<18)+(n[this.charAt(i-1)]<<12);e.push((u&16711680)>>16)}return e},...s}}),typeof Iterator<"u"&&l(Iterator.prototype,{toArray:{value:function(){return Array.from(this)},...s}}),l(Array,{...v()}),l(Array.prototype,{...d(["length","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...p(["push","push0"],["pop","pop0"],["shift","shift0"],["unshift","unshift0"]),...x(["push","push1"],["unshift","unshift1"]),...y(["push","push3"],["unshift","unshift3"]),first0:{value:function(t=null){return this.length?this[0]:t},...s},last0:{value:function(t=null){return this.length?this[this.length-1]:t},...s},find0:{value:function(t,e=null){return this.find(t)??e},...s},equals0:{value:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},...s},unique0:{value:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...s},...p(["forEach","each0"]),toObject:{value:function(t=(e,n)=>[n,e]){return Object.fromEntries(this.map(t))},...s},toMap:{value:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},...s},toSet:{value:function(t=e=>e){return new Set(this.map(t))},...s},toGroup:{value:function(t=e=>[e.id,e]){const e={};for(const n of this){const[r,i]=t(n);r in e||(e[r]=[]),e[r].push(i)}return e},...s},toMerge:{value:function(t=r=>r.id,e=r=>({...r,children:[]}),n=(r,i)=>r.children.push(i)){const r=[];for(const i of this)n(r.find(u=>t(u)==t(i))??r.push1(e(i)),i);return r},...s},bytes2hex:{value:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},...s},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)},...s},base64encode:{value:function(t=!1,e=!0){let n="",r=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let i=2;i<this.length;i+=3){const u=(this[i-2]<<16)+(this[i-1]<<8)+this[i];n+=r.charAt((u&16515072)>>18)+r.charAt((u&258048)>>12)+r.charAt((u&4032)>>6)+r.charAt(u&63)}if(this.length%3==2){const i=(this[this.length-2]<<16)+(this[this.length-1]<<8);n+=r.charAt((i&16515072)>>18)+r.charAt((i&258048)>>12)+r.charAt((i&4032)>>6)+(e===!1?"":"=")}else if(this.length%3==1){const i=this[this.length-1]<<16;n+=r.charAt((i&16515072)>>18)+r.charAt((i&258048)>>12)+(e===!1?"":"==")}return n},...s},toUint8Array:{value:function(){return new Uint8Array(this)},...s},assoc:{value: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)},...s},toTree:{value:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:u="parent",children:o="children",empty:f=null,hasRoot:c=!0}=t,b=this.toObject(a=>[a[e],a]),g=this.toGroup(a=>[a[n],a]),h=this.length&&c?this.find(a=>a[n]===0):{[e]:0,[n]:-1,[i]:null,[u]:null,[o]:g[0]};l(h,{[i]:{value:h,enumerable:!1,configurable:!0,writable:!0}});for(const a of this)l(a,{[i]:{value:h,enumerable:!1,configurable:!0,writable:!0},[u]:{value:b[a[n]],enumerable:!1,configurable:!0,writable:!0}}),a[o]=g[a[e]]||f;return h.treeEach0(a=>a[r]=a[u]?a[u][r]+1:0,-1,o),h},...s},tree2tree:{value:function(t={},e=null,n=null){var g;const{id:r="id",pid:i="pid",level:u="level",root:o="root",parent:f="parent",children:c="children",empty:b=null}=t;e=e||{[r]:0,[i]:-1,[u]:0,[o]:null,[f]:null,[c]:this},n=n||e;for(const h of this)l(h,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[f]:{value:n,enumerable:!1,configurable:!0,writable:!0}}),h[i]=n[r],h[u]=n[u]+1,h[c]=h[c]&&h[c].length?h[c]:b,(g=h[c])==null||g.tree2tree(t,e,h);return e},...s},treeFind0:{value: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},...s},treeEach0:{value:function(t,e=!0,n=-1,r="children"){for(const i of this)i.treeEach0(t,e,n,r);return this},...s},treeMap0:{value:function(t,e=!0,n=-1,r="children",i=null){return this.map(u=>u.treeMap0(t,e,n,r,i))},...s}}),l(ArrayBuffer.prototype,{toUint8Array:{value:function(){return new Uint8Array(this)},...s}}),l(Uint8Array.prototype,{...O(Array.prototype,"bytes2hex","bytes2string","base64encode"),toArray:{value:function(){return new Array(...this)},...s}}),l(Map,{...v()}),l(Map.prototype,{...d(["size","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...p(["set","set0"],["delete","delete0"]),...y(["set","set3"]),get0:{value:function(t,e=null){return this.has(t)?this.get(t):e},...s},get1:{value:function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,e(t,...n))[1]},...s},getAsync1:{value:async function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,await e(t,...n))[1]},...s},toObject:{value:function(){return Object.fromEntries(this)},...s},toArray:{value:function(){return[...this]},...s},toJSON:{value:function(){return[...this]},...s}}),l(Set,{...v()}),l(Set.prototype,{...d(["size","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...p(["add","add0"],["delete","delete0"]),...y(["add","add3"]),toArray:{value:function(){return[...this]},...s},toJSON:{value:function(){return[...this]},...s}}),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)},...s},format:{value:function(t="y-m-d h:i:s"){return new Date().format(t)},...s},unix:{value:function(){return this.now()/1e3|0},...s},fromUnix:{value:function(t=0){return new Date((t||0)*1e3)},...s},expr:{value:function(t={}){return new Date().expr(t)},...s},toDayRange:{value: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]},...s},toWeekRange:{value: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]},...s},toMonthRange:{value: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]},...s},toYearRange:{value: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]},...s}}),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,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="l"?3:2,"0"))},...s},unix:{value:function(){return this.getTime()/1e3|0},...s},isLeapYear:{value:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},...s},getMonthDay:{value:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},...s},expr:{value: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)},...s},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))},...s},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))},...s},week:{value:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},...s},toJSON:{value:function(){return this.getTime()},...s}}),l(RegExp,{...v()}),l(RegExp.prototype,{toJSON:{value:function(){return this.toString()},...s}}),typeof Promise.withResolvers>"u"&&l(Promise,{withResolvers:{value:function(){let t=null,e=null;return{promise:new this((r,i)=>{t=r,e=i}),resolve:t,reject:e}},...s}}),l(Promise,{channel:{value:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]},...s}}),l(Promise.prototype,{tryCatch:{value:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))},...s}}),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}},...s}})});
|