esexts 2.2.3 → 2.2.5
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.cjs +1 -1
- package/dist/esexts.d.ts +87 -37
- package/dist/esexts.js +54 -51
- package/dist/esexts.umd.js +1 -1
- package/package.json +7 -9
package/dist/esexts.cjs
CHANGED
|
@@ -1 +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);
|
|
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,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 r(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 i(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 a=i({array:!1}),o=i({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return a(this,...e)},concat:function(...e){return o(this,...e)}}),e(Object.prototype,{$stringify:function(...e){return JSON.stringify(this,...e)},$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},$empty:function(){return this.$length()===0},...n(Object,0,``,`entries`,`keys`,`values`,`assign`),$merge:function(...e){return a(this,...e)},$concat:function(...e){return o(this,...e)},$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]},...n(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,{...n(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,{$length:function(){return this.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,{$length:function(){return this.length},...r(Array.prototype,`entries`,`keys`,`values`),...n(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...n(Array.prototype,null,`a`,`push`,`unshift`),...n(Array.prototype,null,0,`push`,`unshift`),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)))},...n(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,{$clone:function(){return new Map(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Map.prototype,`entries`,`keys`,`values`),...n(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...n(Map.prototype,null,`a`,`set`,`delete`),...n(Map.prototype,null,0,`set`,`delete`),...n(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,{$clone:function(){return new Set(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Set.prototype,`entries`,`keys`,`values`),...n(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...n(Set.prototype,null,`a`,`add`,`delete`),...n(Set.prototype,null,0,`add`,`delete`),...n(Set.prototype,null,1,`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 s=0,c=0,l=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++s},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===l?e*2048+ ++c%2048:(l=e)*2048+(c=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 u=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(u,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=u);
|
package/dist/esexts.d.ts
CHANGED
|
@@ -40,17 +40,32 @@ declare global {
|
|
|
40
40
|
* Object 实例扩展
|
|
41
41
|
*/
|
|
42
42
|
interface Object {
|
|
43
|
+
/**
|
|
44
|
+
* 将值转换为 JSON 字符串
|
|
45
|
+
* @param v 要转换的值
|
|
46
|
+
* @param replacer 替换函数或数组
|
|
47
|
+
* @param space 缩进空格
|
|
48
|
+
* @returns JSON 字符串
|
|
49
|
+
*/
|
|
50
|
+
$stringify(replacer?: any, space?: string | number): string;
|
|
51
|
+
|
|
43
52
|
/**
|
|
44
53
|
* 克隆对象
|
|
45
54
|
* @returns 克隆后的新对象
|
|
46
55
|
*/
|
|
47
|
-
$clone():
|
|
56
|
+
$clone(): this;
|
|
48
57
|
|
|
49
58
|
/**
|
|
50
59
|
* 获取对象的长度(属性数量)
|
|
51
60
|
* @returns 对象的属性数量
|
|
52
61
|
*/
|
|
53
62
|
$length(): number;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 检查对象是否为空
|
|
66
|
+
* @returns 如果对象为空返回 true,否则返回 false
|
|
67
|
+
*/
|
|
68
|
+
$empty(): boolean;
|
|
54
69
|
|
|
55
70
|
/**
|
|
56
71
|
* 获取对象的键值对迭代器
|
|
@@ -77,15 +92,6 @@ declare global {
|
|
|
77
92
|
*/
|
|
78
93
|
$assign(...sources: any[]): Record<string, any>;
|
|
79
94
|
|
|
80
|
-
/**
|
|
81
|
-
* 将值转换为 JSON 字符串
|
|
82
|
-
* @param v 要转换的值
|
|
83
|
-
* @param replacer 替换函数或数组
|
|
84
|
-
* @param space 缩进空格
|
|
85
|
-
* @returns JSON 字符串
|
|
86
|
-
*/
|
|
87
|
-
$stringify(replacer?: any, space?: string | number): string;
|
|
88
|
-
|
|
89
95
|
/**
|
|
90
96
|
* 合并多个对象到当前对象
|
|
91
97
|
* @param args 要合并的对象列表
|
|
@@ -100,12 +106,6 @@ declare global {
|
|
|
100
106
|
*/
|
|
101
107
|
$concat(...args: Record<string, any>[]): Record<string, any>;
|
|
102
108
|
|
|
103
|
-
/**
|
|
104
|
-
* 检查对象是否为空
|
|
105
|
-
* @returns 如果对象为空返回 true,否则返回 false
|
|
106
|
-
*/
|
|
107
|
-
$empty(): boolean;
|
|
108
|
-
|
|
109
109
|
/**
|
|
110
110
|
* 检查对象是否包含指定键
|
|
111
111
|
* @param key 要检查的键
|
|
@@ -692,11 +692,32 @@ declare global {
|
|
|
692
692
|
* Array 实例扩展
|
|
693
693
|
*/
|
|
694
694
|
interface Array<T> {
|
|
695
|
+
/**
|
|
696
|
+
* 将值转换为 JSON 字符串
|
|
697
|
+
* @param v 要转换的值
|
|
698
|
+
* @param replacer 替换函数或数组
|
|
699
|
+
* @param space 缩进空格
|
|
700
|
+
* @returns JSON 字符串
|
|
701
|
+
*/
|
|
702
|
+
$stringify(replacer?: any, space?: string | number): string;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* 克隆数组
|
|
706
|
+
* @returns 克隆后的新数组
|
|
707
|
+
*/
|
|
708
|
+
$clone(): this;
|
|
709
|
+
|
|
695
710
|
/**
|
|
696
711
|
* 获取数组长度
|
|
697
712
|
* @returns 数组长度
|
|
698
713
|
*/
|
|
699
714
|
$length(): number;
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* 检查数组是否为空
|
|
718
|
+
* @returns 如果数组为空返回 true,否则返回 false
|
|
719
|
+
*/
|
|
720
|
+
$empty(): boolean;
|
|
700
721
|
|
|
701
722
|
/**
|
|
702
723
|
* 获取数组的键值对迭代器
|
|
@@ -715,14 +736,7 @@ declare global {
|
|
|
715
736
|
* @returns 值迭代器
|
|
716
737
|
*/
|
|
717
738
|
$values(): T[];
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* 映射数组元素
|
|
721
|
-
* @param callback 映射函数
|
|
722
|
-
* @returns 映射后的新数组
|
|
723
|
-
*/
|
|
724
|
-
$map<U>(callback: (v: T, i: number, array: T[]) => U): U[];
|
|
725
|
-
|
|
739
|
+
|
|
726
740
|
/**
|
|
727
741
|
* 向数组末尾添加元素, 并返回当前数组
|
|
728
742
|
* @param items 要添加的元素
|
|
@@ -786,12 +800,6 @@ declare global {
|
|
|
786
800
|
*/
|
|
787
801
|
$unshift0(...items: T[]): T;
|
|
788
802
|
|
|
789
|
-
/**
|
|
790
|
-
* 检查数组是否为空
|
|
791
|
-
* @returns 如果数组为空返回 true,否则返回 false
|
|
792
|
-
*/
|
|
793
|
-
$empty(): boolean;
|
|
794
|
-
|
|
795
803
|
/**
|
|
796
804
|
* 获取数组的第一个元素
|
|
797
805
|
* @param defval 默认值
|
|
@@ -951,10 +959,31 @@ declare global {
|
|
|
951
959
|
*/
|
|
952
960
|
interface Map<K, V> {
|
|
953
961
|
/**
|
|
954
|
-
*
|
|
955
|
-
* @
|
|
962
|
+
* 将值转换为 JSON 字符串
|
|
963
|
+
* @param v 要转换的值
|
|
964
|
+
* @param replacer 替换函数或数组
|
|
965
|
+
* @param space 缩进空格
|
|
966
|
+
* @returns JSON 字符串
|
|
967
|
+
*/
|
|
968
|
+
$stringify(replacer?: any, space?: string | number): string;
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* 克隆 Map
|
|
972
|
+
* @returns 克隆后的新 Map
|
|
973
|
+
*/
|
|
974
|
+
$clone(): this;
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* 获取 Map 长度
|
|
978
|
+
* @returns Map 长度
|
|
956
979
|
*/
|
|
957
980
|
$length(): number;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* 检查 Map 是否为空
|
|
984
|
+
* @returns 如果 Map 为空返回 true,否则返回 false
|
|
985
|
+
*/
|
|
986
|
+
$empty(): boolean;
|
|
958
987
|
|
|
959
988
|
/**
|
|
960
989
|
* 获取 Map 的键值对迭代器
|
|
@@ -1122,28 +1151,49 @@ declare global {
|
|
|
1122
1151
|
*/
|
|
1123
1152
|
interface Set<T> {
|
|
1124
1153
|
/**
|
|
1125
|
-
*
|
|
1126
|
-
* @
|
|
1154
|
+
* 将值转换为 JSON 字符串
|
|
1155
|
+
* @param v 要转换的值
|
|
1156
|
+
* @param replacer 替换函数或数组
|
|
1157
|
+
* @param space 缩进空格
|
|
1158
|
+
* @returns JSON 字符串
|
|
1159
|
+
*/
|
|
1160
|
+
$stringify(replacer?: any, space?: string | number): string;
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* 克隆 Set
|
|
1164
|
+
* @returns 克隆后的新 Set
|
|
1165
|
+
*/
|
|
1166
|
+
$clone(): this;
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* 获取 Set 长度
|
|
1170
|
+
* @returns Set 长度
|
|
1127
1171
|
*/
|
|
1128
1172
|
$length(): number;
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* 检查 Set 是否为空
|
|
1176
|
+
* @returns 如果 Set 为空返回 true,否则返回 false
|
|
1177
|
+
*/
|
|
1178
|
+
$empty(): boolean;
|
|
1129
1179
|
|
|
1130
1180
|
/**
|
|
1131
1181
|
* 获取 Set 的键值对迭代器
|
|
1132
1182
|
* @returns 键值对迭代器
|
|
1133
1183
|
*/
|
|
1134
|
-
$entries():
|
|
1184
|
+
$entries(): [number, T][];
|
|
1135
1185
|
|
|
1136
1186
|
/**
|
|
1137
1187
|
* 获取 Set 的键迭代器
|
|
1138
1188
|
* @returns 键迭代器
|
|
1139
1189
|
*/
|
|
1140
|
-
$keys():
|
|
1190
|
+
$keys(): number[];
|
|
1141
1191
|
|
|
1142
1192
|
/**
|
|
1143
1193
|
* 获取 Set 的值迭代器
|
|
1144
1194
|
* @returns 值迭代器
|
|
1145
1195
|
*/
|
|
1146
|
-
$values():
|
|
1196
|
+
$values(): T[];
|
|
1147
1197
|
|
|
1148
1198
|
/**
|
|
1149
1199
|
* 添加元素, 并返回当前Map
|
package/dist/esexts.js
CHANGED
|
@@ -12,17 +12,7 @@ function t() {
|
|
|
12
12
|
return new this(...e);
|
|
13
13
|
} };
|
|
14
14
|
}
|
|
15
|
-
function n(...
|
|
16
|
-
let t = {};
|
|
17
|
-
for (let n of e) {
|
|
18
|
-
let [e, r] = Array.isArray(n) ? n : [n, "$" + n];
|
|
19
|
-
t[r] = function() {
|
|
20
|
-
return this[e];
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return t;
|
|
24
|
-
}
|
|
25
|
-
function r(e, t, n, ...r) {
|
|
15
|
+
function n(e, t, n, ...r) {
|
|
26
16
|
let i = {}, a = (e, t, n) => (t !== null && e.splice(t >= 0 ? t : e.length + t + 1, 0, n), e);
|
|
27
17
|
for (let o of r) {
|
|
28
18
|
let [r, s] = Array.isArray(o) ? o : [o, "$" + o + n.toString().replaceAll("-", "_")];
|
|
@@ -45,7 +35,7 @@ function r(e, t, n, ...r) {
|
|
|
45
35
|
}
|
|
46
36
|
return i;
|
|
47
37
|
}
|
|
48
|
-
function
|
|
38
|
+
function r(e, ...t) {
|
|
49
39
|
let n = {};
|
|
50
40
|
for (let r of t) {
|
|
51
41
|
let [t, i] = Array.isArray(r) ? r : [r, "$" + r];
|
|
@@ -57,7 +47,7 @@ function i(e, ...t) {
|
|
|
57
47
|
}
|
|
58
48
|
//#endregion
|
|
59
49
|
//#region lib/Object.js
|
|
60
|
-
function
|
|
50
|
+
function i(e = { array: !1 }) {
|
|
61
51
|
return function(t = {}, ...n) {
|
|
62
52
|
let r = (t, n) => {
|
|
63
53
|
let i = Object.prototype.toString.call(t);
|
|
@@ -72,35 +62,37 @@ function a(e = { array: !1 }) {
|
|
|
72
62
|
return t;
|
|
73
63
|
};
|
|
74
64
|
}
|
|
75
|
-
var
|
|
65
|
+
var a = i({ array: !1 }), o = i({ array: !0 });
|
|
76
66
|
e(Object, {
|
|
77
67
|
...t(),
|
|
78
68
|
isObject: function(e) {
|
|
79
69
|
return Object.prototype.toString.call(e) === "[object Object]";
|
|
80
70
|
},
|
|
81
71
|
merge: function(...e) {
|
|
82
|
-
return
|
|
72
|
+
return a(this, ...e);
|
|
83
73
|
},
|
|
84
74
|
concat: function(...e) {
|
|
85
|
-
return
|
|
75
|
+
return o(this, ...e);
|
|
86
76
|
}
|
|
87
77
|
}), e(Object.prototype, {
|
|
78
|
+
$stringify: function(...e) {
|
|
79
|
+
return JSON.stringify(this, ...e);
|
|
80
|
+
},
|
|
88
81
|
$clone: function() {
|
|
89
82
|
return JSON.parse(JSON.stringify(this));
|
|
90
83
|
},
|
|
91
84
|
$length: function() {
|
|
92
85
|
return Object.keys(this).length;
|
|
93
86
|
},
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
$empty: function() {
|
|
88
|
+
return this.$length() === 0;
|
|
89
|
+
},
|
|
90
|
+
...n(Object, 0, "", "entries", "keys", "values", "assign"),
|
|
96
91
|
$merge: function(...e) {
|
|
97
|
-
return
|
|
92
|
+
return a(this, ...e);
|
|
98
93
|
},
|
|
99
94
|
$concat: function(...e) {
|
|
100
|
-
return
|
|
101
|
-
},
|
|
102
|
-
$empty: function() {
|
|
103
|
-
return Object.keys(this).length == 0;
|
|
95
|
+
return o(this, ...e);
|
|
104
96
|
},
|
|
105
97
|
$has: function(e) {
|
|
106
98
|
return e in this;
|
|
@@ -135,7 +127,7 @@ e(Object, {
|
|
|
135
127
|
$toArray: function() {
|
|
136
128
|
return Array.isArray(this) ? this : [this];
|
|
137
129
|
},
|
|
138
|
-
...
|
|
130
|
+
...n(console, -1, "t", ["debug", "$debug"], ["log", "$log"], ["info", "$info"], ["warn", "$warn"], ["error", "$error"], ["dir", "$dir"]),
|
|
139
131
|
$debugger: function(...e) {
|
|
140
132
|
return console.debug(this, ...e), this;
|
|
141
133
|
},
|
|
@@ -172,7 +164,7 @@ e(Object, {
|
|
|
172
164
|
return a[r] = o, a;
|
|
173
165
|
}
|
|
174
166
|
}), e(Number.prototype, {
|
|
175
|
-
...
|
|
167
|
+
...n(Math, 0, "", ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
|
|
176
168
|
fixed: function(e = 0) {
|
|
177
169
|
return +this.toFixed(e);
|
|
178
170
|
},
|
|
@@ -218,7 +210,9 @@ e(Object, {
|
|
|
218
210
|
}), e(BigInt.prototype, { toJSON: function() {
|
|
219
211
|
return this >= BigInt(-(2 ** 53 - 1)) && this <= BigInt(2 ** 53 - 1) ? Number(this) : this.toString();
|
|
220
212
|
} }), e(String, { ...t() }), e(String.prototype, {
|
|
221
|
-
|
|
213
|
+
$length: function() {
|
|
214
|
+
return this.length;
|
|
215
|
+
},
|
|
222
216
|
$substring: function(e = 0, t = this.length) {
|
|
223
217
|
return e = e >= 0 ? e : this.length + e, t = t >= 0 ? t : this.length + t, this.substring(e, t);
|
|
224
218
|
},
|
|
@@ -317,15 +311,13 @@ e(Object, {
|
|
|
317
311
|
return t;
|
|
318
312
|
}
|
|
319
313
|
}), e(Array.prototype, {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
...r(Array.prototype, null, "", "map"),
|
|
323
|
-
...r(Array.prototype, null, "t", ["push", "$push"], ["pop", "$pop"], ["shift", "$shift"], ["unshift", "$unshift"], ["splice", "$splice"]),
|
|
324
|
-
...r(Array.prototype, null, "a", "push", "unshift"),
|
|
325
|
-
...r(Array.prototype, null, 0, "push", "unshift"),
|
|
326
|
-
$empty: function() {
|
|
327
|
-
return this.length == 0;
|
|
314
|
+
$length: function() {
|
|
315
|
+
return this.length;
|
|
328
316
|
},
|
|
317
|
+
...r(Array.prototype, "entries", "keys", "values"),
|
|
318
|
+
...n(Array.prototype, null, "t", ["push", "$push"], ["pop", "$pop"], ["shift", "$shift"], ["unshift", "$unshift"], ["splice", "$splice"]),
|
|
319
|
+
...n(Array.prototype, null, "a", "push", "unshift"),
|
|
320
|
+
...n(Array.prototype, null, 0, "push", "unshift"),
|
|
329
321
|
first: function(e = null) {
|
|
330
322
|
return this.length ? this[0] : e;
|
|
331
323
|
},
|
|
@@ -342,7 +334,7 @@ e(Object, {
|
|
|
342
334
|
let t = /* @__PURE__ */ new Set();
|
|
343
335
|
return this.filter((n) => t.has(e(n)) ? !1 : !!t.add(e(n)));
|
|
344
336
|
},
|
|
345
|
-
...
|
|
337
|
+
...n(Array.prototype, null, "t", ["forEach", "each"]),
|
|
346
338
|
each$async: async function(e) {
|
|
347
339
|
for (let t = 0; t < this.length; t++) await e(this[t], t, this);
|
|
348
340
|
return this;
|
|
@@ -440,12 +432,17 @@ e(Object, {
|
|
|
440
432
|
return this.map((a) => a.$tree$map(e, t, n, r, i));
|
|
441
433
|
}
|
|
442
434
|
}), e(Map, { ...t() }), e(Map.prototype, {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
435
|
+
$clone: function() {
|
|
436
|
+
return new Map(JSON.parse(JSON.stringify(this)));
|
|
437
|
+
},
|
|
438
|
+
$length: function() {
|
|
439
|
+
return this.size;
|
|
440
|
+
},
|
|
441
|
+
...r(Map.prototype, "entries", "keys", "values"),
|
|
442
|
+
...n(Map.prototype, null, "t", ["set", "$set"], ["delete", "$delete"]),
|
|
443
|
+
...n(Map.prototype, null, "a", "set", "delete"),
|
|
444
|
+
...n(Map.prototype, null, 0, "set", "delete"),
|
|
445
|
+
...n(Map.prototype, null, 1, "set", "delete"),
|
|
449
446
|
$getOrInsert: function(e, t = null) {
|
|
450
447
|
return this.has(e) ? this.get(e) : this.$set1(e, t);
|
|
451
448
|
},
|
|
@@ -468,11 +465,17 @@ e(Object, {
|
|
|
468
465
|
return [...this];
|
|
469
466
|
}
|
|
470
467
|
}), Map.prototype.getOrInsert === void 0 && (Map.prototype.getOrInsert = Map.prototype.$getOrInsert, Map.prototype.getOrInsertComputed = Map.prototype.$getOrInsertComputed), e(Set, { ...t() }), e(Set.prototype, {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
468
|
+
$clone: function() {
|
|
469
|
+
return new Set(JSON.parse(JSON.stringify(this)));
|
|
470
|
+
},
|
|
471
|
+
$length: function() {
|
|
472
|
+
return this.size;
|
|
473
|
+
},
|
|
474
|
+
...r(Set.prototype, "entries", "keys", "values"),
|
|
475
|
+
...n(Set.prototype, null, "t", ["add", "$add"], ["delete", "$delete"]),
|
|
476
|
+
...n(Set.prototype, null, "a", "add", "delete"),
|
|
477
|
+
...n(Set.prototype, null, 0, "add", "delete"),
|
|
478
|
+
...n(Set.prototype, null, 1, "add", "delete"),
|
|
476
479
|
$union: function(e) {
|
|
477
480
|
return new Set([...this, ...e]);
|
|
478
481
|
},
|
|
@@ -724,7 +727,7 @@ e(Object, {
|
|
|
724
727
|
}), 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);
|
|
725
728
|
//#endregion
|
|
726
729
|
//#region lib/Math.js
|
|
727
|
-
var
|
|
730
|
+
var s = 0, c = 0, l = 0;
|
|
728
731
|
e(Math, {
|
|
729
732
|
randstr: function(e = 16, t = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", r = "~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/") {
|
|
730
733
|
if (e < t) throw Error("randstr: len < slen");
|
|
@@ -742,13 +745,13 @@ e(Math, {
|
|
|
742
745
|
return Math.floor(Math.random() * (t - e) + e);
|
|
743
746
|
},
|
|
744
747
|
incrid: function() {
|
|
745
|
-
return ++
|
|
748
|
+
return ++s;
|
|
746
749
|
},
|
|
747
750
|
incrstr: function() {
|
|
748
751
|
return "" + Math.incrid();
|
|
749
752
|
},
|
|
750
753
|
uniqid: function(e = Date.now()) {
|
|
751
|
-
return e ===
|
|
754
|
+
return e === l ? e * 2048 + ++c % 2048 : (l = e) * 2048 + (c = 0) % 2048;
|
|
752
755
|
},
|
|
753
756
|
uniqstr: function() {
|
|
754
757
|
return "" + Math.uniqid();
|
|
@@ -776,7 +779,7 @@ e(Math, {
|
|
|
776
779
|
});
|
|
777
780
|
//#endregion
|
|
778
781
|
//#region lib/LRU.js
|
|
779
|
-
var
|
|
782
|
+
var u = class extends Map {
|
|
780
783
|
constructor(e) {
|
|
781
784
|
super(), this.capacity = e;
|
|
782
785
|
}
|
|
@@ -807,5 +810,5 @@ var d = class extends Map {
|
|
|
807
810
|
return this.set(e, t);
|
|
808
811
|
}
|
|
809
812
|
};
|
|
810
|
-
e(
|
|
813
|
+
e(u, { ...t() }), globalThis.LRU === void 0 && (globalThis.LRU = u);
|
|
811
814
|
//#endregion
|
package/dist/esexts.umd.js
CHANGED
|
@@ -1 +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)});
|
|
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,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 r(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 i(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 a=i({array:!1}),o=i({array:!0});e(Object,{...t(),isObject:function(e){return Object.prototype.toString.call(e)===`[object Object]`},merge:function(...e){return a(this,...e)},concat:function(...e){return o(this,...e)}}),e(Object.prototype,{$stringify:function(...e){return JSON.stringify(this,...e)},$clone:function(){return JSON.parse(JSON.stringify(this))},$length:function(){return Object.keys(this).length},$empty:function(){return this.$length()===0},...n(Object,0,``,`entries`,`keys`,`values`,`assign`),$merge:function(...e){return a(this,...e)},$concat:function(...e){return o(this,...e)},$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]},...n(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,{...n(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,{$length:function(){return this.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,{$length:function(){return this.length},...r(Array.prototype,`entries`,`keys`,`values`),...n(Array.prototype,null,`t`,[`push`,`$push`],[`pop`,`$pop`],[`shift`,`$shift`],[`unshift`,`$unshift`],[`splice`,`$splice`]),...n(Array.prototype,null,`a`,`push`,`unshift`),...n(Array.prototype,null,0,`push`,`unshift`),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)))},...n(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,{$clone:function(){return new Map(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Map.prototype,`entries`,`keys`,`values`),...n(Map.prototype,null,`t`,[`set`,`$set`],[`delete`,`$delete`]),...n(Map.prototype,null,`a`,`set`,`delete`),...n(Map.prototype,null,0,`set`,`delete`),...n(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,{$clone:function(){return new Set(JSON.parse(JSON.stringify(this)))},$length:function(){return this.size},...r(Set.prototype,`entries`,`keys`,`values`),...n(Set.prototype,null,`t`,[`add`,`$add`],[`delete`,`$delete`]),...n(Set.prototype,null,`a`,`add`,`delete`),...n(Set.prototype,null,0,`add`,`delete`),...n(Set.prototype,null,1,`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 s=0,c=0,l=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++s},incrstr:function(){return``+Math.incrid()},uniqid:function(e=Date.now()){return e===l?e*2048+ ++c%2048:(l=e)*2048+(c=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 u=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(u,{...t()}),globalThis.LRU===void 0&&(globalThis.LRU=u)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esexts",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "esexts",
|
|
5
5
|
"author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
|
|
6
6
|
"homepage": "https://github.com/dotcoo/esexts#readme",
|
|
@@ -25,16 +25,14 @@
|
|
|
25
25
|
"require": "./dist/esexts.cjs",
|
|
26
26
|
"browser": "./dist/esexts.umd.js"
|
|
27
27
|
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^6.0.3",
|
|
30
|
+
"vite": "^8.0.16",
|
|
31
|
+
"vite-plugin-dts": "^5.0.2"
|
|
32
|
+
},
|
|
28
33
|
"scripts": {
|
|
29
34
|
"dev": "vite",
|
|
30
35
|
"build": "vite build",
|
|
31
36
|
"preview": "vite preview"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"vite": "^8.0.16"
|
|
35
|
-
},
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"typescript": "^6.0.3",
|
|
38
|
-
"vite-plugin-dts": "^5.0.2"
|
|
39
37
|
}
|
|
40
|
-
}
|
|
38
|
+
}
|