esexts 2.2.1 → 2.2.3

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.
@@ -0,0 +1 @@
1
+ "use strict";function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(...e){let t={};for(let n of e){let[e,r]=Array.isArray(n)?n:[n,`$`+n];t[r]=function(){return this[e]}}return t}function r(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function i(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function a(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var o=a({array:!1}),s=a({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return o(this,...e)},concat:function(...e){return s(this,...e)}}),e(Object.prototype,{$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},...r(Object,0,``,`entries`,`keys`,`values`,`assign`),...r(JSON,0,``,`stringify`),$merge:function(...e){return o(this,...e)},$concat:function(...e){return s(this,...e)},$empty:function(){return Object.keys(this).length==0},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n=void 0,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}={}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...r(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...r(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{...n([`length`,`length$`]),$substring: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)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{...n(`length`),...i(Array.prototype,`entries`,`keys`,`values`),...r(Array.prototype,null,``,`map`),...r(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...r(Array.prototype,null,`a`,`push`,`unshift`),...r(Array.prototype,null,0,`push`,`unshift`),$empty:function(){return this.length==0},first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...r(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],{exists:!1}).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{...n([`size`,`$length`]),...i(Map.prototype,`entries`,`keys`,`values`),...r(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...r(Map.prototype,null,`a`,`set`,`delete`),...r(Map.prototype,null,0,`set`,`delete`),...r(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{...n([`size`,`$length`]),...i(Set.prototype,`entries`,`keys`,`values`),...r(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...r(Set.prototype,null,`a`,`add`,`delete`),...r(Set.prototype,null,0,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let 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])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin: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))},end: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))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var c=0,l=0,u=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++c},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===u?e*2048+ ++l%2048:(u=e)*2048+(l=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var d=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(d,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=d);
package/dist/esexts.js CHANGED
@@ -117,7 +117,7 @@ e(Object, {
117
117
  },
118
118
  $attr: function(...e) {
119
119
  if (typeof this != "object") return this;
120
- let [t, n, { defval: r, exists: i, define: a, add: o, sub: s, mul: c, div: l }] = e;
120
+ let [t, n = void 0, { defval: r, exists: i, define: a, add: o, sub: s, mul: c, div: l } = {}] = e;
121
121
  return e.length == 1 ? this[t] : e.length == 2 ? (this[t] = n, this) : r === void 0 ? typeof i == "boolean" ? (t in this === i && (this[t] = n), this) : a === void 0 ? o === void 0 ? s === void 0 ? c === void 0 ? (l === void 0 || (this[t] = (t in this ? this[t] : r) / l), this) : (this[t] = (t in this ? this[t] : r) * c, this) : (this[t] = (t in this ? this[t] : r) - s, this) : (this[t] = (t in this ? this[t] : r) + o, this) : Object.defineProperty(this, t, {
122
122
  value: n,
123
123
  enumerable: !1,
@@ -395,7 +395,7 @@ e(Object, {
395
395
  return this.each$((n) => n[t] = i[n[e]] ?? null);
396
396
  },
397
397
  toTree: function(t = {}) {
398
- let { id: n = "id", pid: r = "pid", level: i = "level", root: a = "root", parent: o = "parent", children: s = "children", empty: c = null, hasRoot: l = !0 } = t, u = this.reduce((e, t) => e.$attr(t[n], t), {}), d = this.reduce((e, t) => (e.$attr(t[r], [], !1).$attr(t[r]).$push(t), e), {}), f = this.length && l ? this.find((e) => e[r] === 0) : {
398
+ let { id: n = "id", pid: r = "pid", level: i = "level", root: a = "root", parent: o = "parent", children: s = "children", empty: c = null, hasRoot: l = !0 } = t, u = this.reduce((e, t) => e.$attr(t[n], t), {}), d = this.reduce((e, t) => (e.$attr(t[r], [], { exists: !1 }).$attr(t[r]).$push(t), e), {}), f = this.length && l ? this.find((e) => e[r] === 0) : {
399
399
  [n]: 0,
400
400
  [r]: -1,
401
401
  [a]: null,
@@ -0,0 +1 @@
1
+ "use strict";(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(...e){let t={};for(let n of e){let[e,r]=Array.isArray(n)?n:[n,`$`+n];t[r]=function(){return this[e]}}return t}function r(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function i(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function a(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var o=a({array:!1}),s=a({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return o(this,...e)},concat:function(...e){return s(this,...e)}}),e(Object.prototype,{$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},...r(Object,0,``,`entries`,`keys`,`values`,`assign`),...r(JSON,0,``,`stringify`),$merge:function(...e){return o(this,...e)},$concat:function(...e){return s(this,...e)},$empty:function(){return Object.keys(this).length==0},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n=void 0,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}={}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...r(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...r(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{...n([`length`,`length$`]),$substring: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)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{...n(`length`),...i(Array.prototype,`entries`,`keys`,`values`),...r(Array.prototype,null,``,`map`),...r(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...r(Array.prototype,null,`a`,`push`,`unshift`),...r(Array.prototype,null,0,`push`,`unshift`),$empty:function(){return this.length==0},first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...r(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],{exists:!1}).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{...n([`size`,`$length`]),...i(Map.prototype,`entries`,`keys`,`values`),...r(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...r(Map.prototype,null,`a`,`set`,`delete`),...r(Map.prototype,null,0,`set`,`delete`),...r(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{...n([`size`,`$length`]),...i(Set.prototype,`entries`,`keys`,`values`),...r(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...r(Set.prototype,null,`a`,`add`,`delete`),...r(Set.prototype,null,0,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let 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])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin: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))},end: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))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var c=0,l=0,u=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++c},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===u?e*2048+ ++l%2048:(u=e)*2048+(l=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var d=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(d,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=d)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esexts",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "esexts",
5
5
  "author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
6
6
  "homepage": "https://github.com/dotcoo/esexts#readme",
@@ -15,17 +15,15 @@
15
15
  "files": [
16
16
  "LICENSE",
17
17
  "README.md",
18
- "dist",
19
- "types.d.ts"
18
+ "dist"
20
19
  ],
21
20
  "type": "module",
22
- "types": "./types.d.ts",
23
- "main": "./dist/esexts.umd.cjs",
24
- "module": "./dist/esexts.js",
21
+ "main": "./dist/esexts.umd.js",
25
22
  "exports": {
26
- "types": "./types.d.ts",
27
- "require": "./dist/esexts.umd.cjs",
28
- "import": "./dist/esexts.js"
23
+ "types": "./esexts.d.ts",
24
+ "import": "./dist/esexts.js",
25
+ "require": "./dist/esexts.cjs",
26
+ "browser": "./dist/esexts.umd.js"
29
27
  },
30
28
  "scripts": {
31
29
  "dev": "vite",
@@ -33,6 +31,10 @@
33
31
  "preview": "vite preview"
34
32
  },
35
33
  "devDependencies": {
36
- "vite": "^8.0.13"
34
+ "vite": "^8.0.16"
35
+ },
36
+ "dependencies": {
37
+ "typescript": "^6.0.3",
38
+ "vite-plugin-dts": "^5.0.2"
37
39
  }
38
40
  }
@@ -1 +0,0 @@
1
- "use strict";(function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){function e(e,t){return Object.defineProperties(e,Object.fromEntries(Object.keys(t).map(e=>[e,{value:t[e],enumerable:!1,configurable:!0,writable:!0}])))}function t(){return{new:function(...e){return new this(...e)}}}function n(...e){let t={};for(let n of e){let[e,r]=Array.isArray(n)?n:[n,`$`+n];t[r]=function(){return this[e]}}return t}function r(e,t,n,...r){let i={},a=(e,t,n)=>(t!==null&&e.splice(t>=0?t:e.length+t+1,0,n),e);for(let o of r){let[r,s]=Array.isArray(o)?o:[o,`$`+o+n.toString().replaceAll(`-`,`_`)];if(n===``)i[s]=function(...n){return e[r].apply(this,a(n,t,this))};else if(n===`t`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),this};else if(n===`a`)i[s]=function(...n){return e[r].apply(this,a(n,t,this)),n};else if(n>=0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[n]};else if(n<0)i[s]=function(...i){return e[r].apply(this,a(i,t,this)),i[i.length+n]};else throw Error(`unreachable`)}return i}function i(e,...t){let n={};for(let r of t){let[t,i]=Array.isArray(r)?r:[r,`$`+r];n[i]=function(...n){return[...e[t].apply(this,n)]}}return n}function a(e={array:!1}){return function(t={},...n){let r=(t,n)=>{let i=Object.prototype.toString.call(t);if(i!==Object.prototype.toString.call(n))return n;if(i===`[object Array]`)return e.array?t.concat(...n):n;if(i===`[object Object]`){for(let e in n)t[e]=r(t[e],n[e]);return t}else return n};for(let e of n)t=r(t,e);return t}}var o=a({array:!1}),s=a({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return o(this,...e)},concat:function(...e){return s(this,...e)}}),e(Object.prototype,{$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},...r(Object,0,``,`entries`,`keys`,`values`,`assign`),...r(JSON,0,``,`stringify`),$merge:function(...e){return o(this,...e)},$concat:function(...e){return s(this,...e)},$empty:function(){return Object.keys(this).length==0},$has:function(e){return e in this},$pick:function(...e){let t={};for(let n of e)t[n]=this[n];return t},$omit:function(...e){let t={},n=new Set(e);for(let e in this)n.has(e)||(t[e]=this[e]);return t},$attr:function(...e){if(typeof this!=`object`)return this;let[t,n,{defval:r,exists:i,define:a,add:o,sub:s,mul:c,div:l}]=e;return e.length==1?this[t]:e.length==2?(this[t]=n,this):r===void 0?typeof i==`boolean`?(t in this===i&&(this[t]=n),this):a===void 0?o===void 0?s===void 0?c===void 0?(l===void 0||(this[t]=(t in this?this[t]:r)/l),this):(this[t]=(t in this?this[t]:r)*c,this):(this[t]=(t in this?this[t]:r)-s,this):(this[t]=(t in this?this[t]:r)+o,this):Object.defineProperty(this,t,{value:n,enumerable:!1,configurable:!0,writable:!0,...a}):t in this?this[t]:r},$pipe:function(e,...t){return e(this,...t)},$tee:function(e,...t){return e(this,...t),this},$toArray:function(){return Array.isArray(this)?this:[this]},...r(console,-1,`t`,[`debug`,`$debug`],[`log`,`$log`],[`info`,`$info`],[`warn`,`$warn`],[`error`,`$error`],[`dir`,`$dir`]),$debugger:function(...e){return console.debug(this,...e),this},$getParents:function(e=!1,t=-1,n=`parent`){let r=e?[this]:[],i=this[n];for(;i&&t--!=0;)r.push(i),i=i[n];return r},$getChildrens:function(e=!1,t=-1,n=`children`){let r=[],i=(e,t,a)=>{if(t&&r.push(e),!(a==0||!e[n]||e[n].length==0))for(let t of e[n])i(t,!0,a-1)};return i(this,e,t),r},$tree$find:function(e,t=!0,n=-1,r=`children`){if(t&&e(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(let t of this[r]){let i=t.$tree$find(e,!0,n-1,r);if(i!==null)return i}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){if(t&&e(this),!(n==0||!this[r]||this[r].length==0)){for(let t of this[r])t.$tree$each(e,!0,n-1,r);return this}},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){let a=t?e(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return a;for(let t of this[r])o.push(t.$tree$map(e,!0,n-1,r,i));return a[r]=o,a}}),e(Number.prototype,{...r(Math,0,``,[`ceil`,`ceil`],[`floor`,`floor`],[`trunc`,`trunc`],[`abs`,`abs`],[`max`,`max`],[`min`,`min`]),fixed:function(e=0){return+this.toFixed(e)},round:function(e=0){return Math.round(this*10**e)/10**e},add:function(e,...t){return typeof e==`function`?e(this,...t):this+e},sub:function(e,...t){return typeof e==`function`?e(this,...t):this-e},mul:function(e,...t){return typeof e==`function`?e(this,...t):this*e},div:function(e,...t){return typeof e==`function`?e(this,...t):this/e},baseConvert:function(e=64){let t=``,n=this;for(;n>0;)t=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.at(n%e)+t,n=Math.floor(n/e);return t||`0`},unit:function(e,t=0){let n=this,r=``;for(let[t,i]of Object.entries(e)){if(r=t,i===0||n<i)break;n/=i}return t<0?+n.toFixed(0-t)+r:n.toFixed(t)+r},units:function(e,t=!1){let n=this,r=[];for(let[t,i]of Object.entries(e))if(i==0||n<i){r.push([n,t]);break}else r.push([n%i,t]),n=Math.floor(n/i);return t?r:r.reverse().map(([e,t])=>e+t).join(``)},toDate:function(){return Date.new(this)}}),e(BigInt.prototype,{toJSON:function(){return this>=BigInt(-(2**53-1))&&this<=BigInt(2**53-1)?Number(this):this.toString()}}),e(String,{...t()}),e(String.prototype,{...n([`length`,`length$`]),$substring: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)},$substr:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},$split:function(e=`,`,t=-1){let n=this?this.split(e):[];return t===-1?n:n.$push(n.splice(t-1).join(e))},$split$number:function(e=`,`){return this.$split(e).map(e=>+e)},$split$segment:function(e=1){let t=[];for(let n=0;n<this.length;n+=e)t.push(this.substring(n,n+e));return t},sprintf:function(...e){let[t,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)t+=e[r]+n[r];return t},subOf:function(e,t,n=0,r=0){for(let t=0;t<n&&r!=-1;t++,r++)r=this.indexOf(e,r);let i=this.indexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},lastSubOf:function(e,t,n=0,r=1/0){for(let t=0;t<n&&r!=-1;t++,r--)r=this.lastIndexOf(e,r);let i=this.lastIndexOf(e,r),a=this.indexOf(t,i);return i==-1||a==-1?``:(i+=e.length,this.substring(i,a))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(e,t)=>`_`+t.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,`-`)},kebab2under:function(){return this.replace(/-/g,`_`)},baseConvert:function(e=64){let t=0;for(let n=0;n<this.length;n++)t=t*e+`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-`.indexOf(this.at(n));return t},fixed:function(...e){return+(+this).toFixed(...e)},toDate:function(){return Date.new(this)},toUint8Array:function(){return new TextEncoder().encode(this)},hexencode:function(){return new TextEncoder().encode(this).toHex()},hexdecode:function(){return new TextDecoder().decode(Uint8Array.fromHex(this))},base64encode:function(){return new TextEncoder().encode(this).toBase64()},base64decode:function(){return new TextDecoder().decode(Uint8Array.fromBase64(this))}}),e(Array,{...t(),range:function(...e){let t=[],n=0,r=0,i=1,a=typeof e[e.length-1]==`boolean`?e.pop():!0,o=typeof e[e.length-1]==`function`?e.pop():(e,t,n)=>e;switch(e.length){case 1:[r]=e;break;case 2:[n,r]=e;break;case 3:[n,r,i]=e;break;default:throw Error(`the number of parameters is incorrect!`)}if(i==0)throw Error(`step cannot be 0!`);for(let e=0,s=0,c=Math.abs(r-n),l=Math.abs(i),u=n<=r?1:-1;s<c;s+=l)t.push(a?o(n+s*u,e++,t):o());return t}}),e(Array.prototype,{...n(`length`),...i(Array.prototype,`entries`,`keys`,`values`),...r(Array.prototype,null,``,`map`),...r(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...r(Array.prototype,null,`a`,`push`,`unshift`),...r(Array.prototype,null,0,`push`,`unshift`),$empty:function(){return this.length==0},first:function(e=null){return this.length?this[0]:e},last:function(e=null){return this.length?this[this.length-1]:e},$find:function(e,t=null){return this.find(e)??t},equals:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,n)=>t===e[n]))},unique:function(e=e=>e){let t=new Set;return this.filter(n=>t.has(e(n))?!1:!!t.add(e(n)))},...r(Array.prototype,null,`t`,[`forEach`,`each`]),each$async:async function(e){for(let t=0;t<this.length;t++)await e(this[t],t,this);return this},map$async:async function(e){let t=[];for(let n=0;n<this.length;n++)t.push(await e(this[n],n,this));return t},shuffle:function(e=!1){let t=this.length;for(;t;){let e=Math.random()*t--|0;[this[e],this[t]]=[this[t],this[e]]}return this},union:function(e){return Set.new(this).union(Set.new(e)).toArray()},intersection:function(e){return Set.new(this).intersection(Set.new(e)).toArray()},difference:function(e){return Set.new(this).difference(Set.new(e)).toArray()},symmetricDifference:function(e){return Set.new(this).symmetricDifference(Set.new(e)).toArray()},toMap:function(e=(e,t)=>[t,e]){return new Map(this.map(e))},toSet:function(e=e=>e){return new Set(this.map(e))},toUint8Array:function(){return new Uint8Array(this)},toBase64:function(){return this.toUint8Array().toBase64()},toHex:function(){return this.toUint8Array().toHex()},decode:function(){return this.toUint8Array().toString()},assoc:function(e,t,n={}){let r=this.unique$(t=>t[e]),i=r.length==0?{}:typeof n==`function`?n(r):n;return this.each$(n=>n[t]=i[n[e]]??null)},toTree:function(t={}){let{id:n=`id`,pid:r=`pid`,level:i=`level`,root:a=`root`,parent:o=`parent`,children:s=`children`,empty:c=null,hasRoot:l=!0}=t,u=this.reduce((e,t)=>e.$attr(t[n],t),{}),d=this.reduce((e,t)=>(e.$attr(t[r],[],!1).$attr(t[r]).$push(t),e),{}),f=this.length&&l?this.find(e=>e[r]===0):{[n]:0,[r]:-1,[a]:null,[o]:null,[s]:d[0]};e(f,{[a]:f});for(let t of this)e(t,{[a]:f,[o]:u[t[r]]}),t[s]=d[t[n]]||c;return f.$tree$each(e=>e[i]=e[o]?e[o][i]+1:0,-1,s),f},$tree2tree:function(t={},n=null,r=null){let{id:i=`id`,pid:a=`pid`,level:o=`level`,root:s=`root`,parent:c=`parent`,children:l=`children`,empty:u=null}=t;n||={[i]:0,[a]:-1,[o]:0,[s]:null,[c]:null,[l]:this},r||=n;for(let d of this)e(d,{[s]:n,[c]:r}),d[a]=r[i],d[o]=r[o]+1,d[l]=d[l]&&d[l].length?d[l]:u,d[l]?.$tree2tree(t,n,d);return n},$tree$find:function(e,t=!0,n=-1,r=`children`){for(let i of this){let a=i.$tree$find(e,t,n,r);if(a!==null)return a}return null},$tree$each:function(e,t=!0,n=-1,r=`children`){for(let i of this)i.$tree$each(e,t,n,r);return this},$tree$map:function(e,t=!0,n=-1,r=`children`,i=null){return this.map(a=>a.$tree$map(e,t,n,r,i))}}),e(Map,{...t()}),e(Map.prototype,{...n([`size`,`$length`]),...i(Map.prototype,`entries`,`keys`,`values`),...r(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...r(Map.prototype,null,`a`,`set`,`delete`),...r(Map.prototype,null,0,`set`,`delete`),...r(Map.prototype,null,1,`set`,`delete`),$getOrInsert:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,t)},$getOrInsertComputed:function(e,t){return this.has(e)?this.get(e):this.$set1(e,t(e))},$get:function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?t(e):t)},$get$async:async function(e,t=null){return this.has(e)?this.get(e):this.$set1(e,typeof t==`function`?await t(e):t)},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Map.prototype.getOrInsert===void 0&&(Map.prototype.getOrInsert=Map.prototype.$getOrInsert,Map.prototype.getOrInsertComputed=Map.prototype.$getOrInsertComputed),e(Set,{...t()}),e(Set.prototype,{...n([`size`,`$length`]),...i(Set.prototype,`entries`,`keys`,`values`),...r(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...r(Set.prototype,null,`a`,`add`,`delete`),...r(Set.prototype,null,0,`add`,`delete`),$union:function(e){return new Set([...this,...e])},$intersection:function(e){return new Set([...this].filter(t=>e.has(t)))},$difference:function(e){return new Set([...this].filter(t=>!e.has(t)))},$symmetricDifference:function(e){return new Set([...[...this].filter(t=>!e.has(t)),...[...e].filter(e=>!this.has(e))])},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),Set.prototype.union===void 0&&(Set.prototype.union=Set.prototype.$union,Set.prototype.intersection=Set.prototype.$intersection,Set.prototype.difference=Set.prototype.$difference,Set.prototype.symmetricDifference=Set.prototype.$symmetricDifference),e(Date,{new:function(...e){return e.length==1?Number.isNaN(+e[0])?new Date(e[0].includes(`T`)?e[0]:e[0].replace(/-/g,`/`)):new Date(e[0]>25e8?e[0]:e[0]*1e3):new Date(...e)},format:function(e=`y-m-d h:i:s`){return new Date().format(e)},unix:function(){return this.now()/1e3|0},fromUnix:function(e){return new Date((e??0)*1e3)},expr:function(e={}){return new Date().expr(e)},toDayRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){let e=new Date,t=e.getFullYear(),n=e.getMonth();return[new Date(t,n,1).getTime()/1e3|0,new Date(t,n+1,0,23,59,59).getTime()/1e3|0]},toYearRange:function(){let e=new Date().getFullYear();return[new Date(e,1,1).getTime()/1e3|0,new Date(e+1,1,0,23,59,59).getTime()/1e3|0]}}),e(Date.prototype,{format:function(e=`y-m-d h:i:s`){if(this.getTime()===0)return`-`;let 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])/gi,(e,n)=>n>=`A`&&n<=`Z`?t[n.toLowerCase()]:t[n].toString().padStart(n===`l`?3:2,`0`))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4==0&&this.getFullYear()%400!=0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:e=0,m:t=0,d:n=0,h:r=0,i=0,s:a=0}){let o=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+a)},begin: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))},end: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))},week:function(e,t=1){let n=new Date(this.getTime());for(;n.getDay()!==e;)n=new Date(n.getTime()+864e5*t);return n},toJSON:function(){return this.getTime()}}),e(RegExp,{...t()}),e(RegExp.prototype,{toJSON:function(){return this.toString()}}),e(Promise,{...t(),$channel:function(){let e=null,t=null;return[new this((n,r)=>{e=n,t=r}),e,t]},$withResolvers:function(){let e=null,t=null;return{promise:new this((n,r)=>{e=n,t=r}),resolve:e,reject:t}}}),e(Promise.prototype,{tryCatch:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))}}),Promise.withResolvers===void 0&&(Promise.withResolvers=Promise.$withResolvers),e(JSON,{$parse:function(e,t=null){try{if(typeof e!=`string`)throw Error(`not string`);return JSON.parse(e)}catch{return t}}}),typeof Iterator<`u`&&e(Iterator.prototype,{toArray:function(){return[...this]}}),e(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),e(Uint8Array,{...t(),fromString:function(e){return new TextEncoder().encode(e)},$fromHex:function(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Number.parseInt(e.substring(n,n+2),16));return new Uint8Array(t)},$fromBase64:function(e){let t=[],n={};for(let e=0;e<64;e++)n[`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.charAt(e)]=e;let r=e.charAt(e.length-1)==`=`?e.charAt(e.length-2)==`=`?e.length-2:e.length-1:e.length;for(let i=3;i<r;i+=4){let r=(n[e.charAt(i-3)]<<18)+(n[e.charAt(i-2)]<<12)+(n[e.charAt(i-1)]<<6)+n[e.charAt(i)];t.push((r&16711680)>>16,(r&65280)>>8,r&255)}if(r%4==3){let i=(n[e.charAt(r-3)]<<18)+(n[e.charAt(r-2)]<<12)+(n[e.charAt(r-1)]<<6);t.push((i&16711680)>>16,(i&65280)>>8)}else if(r%4==2){let i=(n[e.charAt(r-2)]<<18)+(n[e.charAt(r-1)]<<12);t.push((i&16711680)>>16)}return new Uint8Array(t)}}),e(Uint8Array.prototype,{setFromString(e,t=0){let n=Uint8Array.fromString(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromHex(e,t=0){let n=Uint8Array.fromHex(e);return this.set(n,t),{read:n.length,written:n.length}},$setFromBase64(e,t=0){let n=Uint8Array.fromBase64(e);return this.set(n,t),{read:n.length,written:n.length}},toString:function(){return new TextDecoder().decode(this)},$toHex:function(){let e=``;for(let t=0;t<this.length;t++)e+=(this[t]<16?`0`:``)+this[t].toString(16);return e},$toBase64:function(){let e=``,t={},n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;for(let e=0;e<64;e++)t[n.charAt(e)]=e;for(let t=2;t<this.length;t+=3){let r=(this[t-2]<<16)+(this[t-1]<<8)+this[t];e+=n.charAt((r&16515072)>>18)+n.charAt((r&258048)>>12)+n.charAt((r&4032)>>6)+n.charAt(r&63)}if(this.length%3==2){let t=(this[this.length-2]<<16)+(this[this.length-1]<<8);e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+n.charAt((t&4032)>>6)+`=`}else if(this.length%3==1){let t=this[this.length-1]<<16;e+=n.charAt((t&16515072)>>18)+n.charAt((t&258048)>>12)+`==`}return e},toArray:function(){return new Array(...this)}}),Uint8Array.fromBase64===void 0&&(Uint8Array.fromHex=Uint8Array.$fromHex,Uint8Array.fromBase64=Uint8Array.$fromBase64),Uint8Array.prototype.setFromHex===void 0&&(Uint8Array.prototype.setFromHex=Uint8Array.prototype.$setFromHex,Uint8Array.prototype.setFromBase64=Uint8Array.prototype.$setFromBase64,Uint8Array.prototype.toHex=Uint8Array.prototype.$toHex,Uint8Array.prototype.toBase64=Uint8Array.prototype.$toBase64);var c=0,l=0,u=0;e(Math,{randstr:function(e=16,t=0,n=`0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`,r=`~!@#$%^&*()_+\`{}|[]\\:";'<>,.?/`){if(e<t)throw Error(`randstr: len < slen`);let i=[];for(let t=0;t<e;t++)i.push(n.charAt(Math.random()*n.length|0));for(let n=new Set,a=0,o=0;o<t;o++){do a=Math.random()*e|0;while(n.has(a));n.set(a,!0),i[a]=r.charAt(Math.random()*r.length|0)}return i.join(``)},randint:function(e=0,t=2**53-1){return Math.floor(Math.random()*(t-e)+e)},incrid:function(){return++c},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===u?e*2048+ ++l%2048:(u=e)*2048+(l=0)%2048},uniqstr:function(){return``+Math.uniqid()},sleep:function(e){return new Promise(t=>setTimeout(t,e))},useTemplate:function(e){let t=null,n={setup(e,{slots:n}){return t=n.default,()=>{}},name:e+`Template`},r={setup(e,{attrs:n}){return()=>t?.(n)},name:e};return{[n.name]:n,[r.name]:r}}});var d=class extends Map{constructor(e){super(),this.capacity=e}get(e){if(!super.has(e))return null;let t=super.get(e);return super.delete(e),super.set(e,t),t}getOrInsert(e,t){super.has(e)||super.set(e,t);let n=super.get(e);return super.delete(e),super.set(e,n),n}getOrInsertComputed(e,t){super.has(e)||super.set(e,t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}async getOrInsertComputedAsync(e,t){super.has(e)||super.set(e,await t(e));let n=super.get(e);return super.delete(e),super.set(e,n),n}set(e,t){super.has(e)&&super.delete(e),super.set(e,t),super.size>this.capacity&&super.delete(super.keys().next().value)}put(e,t){return this.set(e,t)}};e(d,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=d)});
File without changes