esexts 1.2.5 → 1.2.6

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.
@@ -1 +1 @@
1
- (function(b){typeof define=="function"&&define.amd?define(b):b()})(function(){"use strict";function b(e={array:!1}){return function(t={},...r){const u=(n,l)=>{const a=Object.prototype.toString.call(n),f=Object.prototype.toString.call(l);if(a!==f)return l;if(a==="[object Array]")return e.array?n.concat(...l):l;if(a==="[object Object]"){for(const o in l)n[o]=u(n[o],l[o]);return n}else return l};for(const n of r)t=u(t,n);return t}}const g=b({array:!1}),m=b({array:!0});Object.defineProperties(Object,{isObject:{value:function(e){return Object.prototype.toString.call(e)==="[object Object]"},enumerable:!1,configurable:!0,writable:!0},merge0:{value:function(...e){return g(this,...e)},enumerable:!1,configurable:!0,writable:!0},concat0:{value:function(...e){return m(this,...e)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Object.prototype,{clone0:{value:function(){return JSON.parse(JSON.stringify(this))},enumerable:!1,configurable:!0,writable:!0},length0:{value:function(){return Object.keys(this).length},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return Object.entries(this)},enumerable:!1,configurable:!0,writable:!0},keys0:{value:function(){return Object.keys(this)},enumerable:!1,configurable:!0,writable:!0},values0:{value:function(){return Object.values(this)},enumerable:!1,configurable:!0,writable:!0},merge0:{value:function(...e){return g(this,...e)},enumerable:!1,configurable:!0,writable:!0},concat0:{value:function(...e){return m(this,...e)},enumerable:!1,configurable:!0,writable:!0},map0:{value:function(e=(r,u,n)=>[r,u],t=0){return Object.entries(this).map(([r,u])=>e(r,u,t++))},enumerable:!1,configurable:!0,writable:!0},pick0:{value:function(...e){const t={};for(const r of e)t[r]=this[r];return t},enumerable:!1,configurable:!0,writable:!0},omit0:{value:function(...e){const t={},r=new Set(e);for(const u in this)r.has(u)||(t[u]=this[u]);return t},enumerable:!1,configurable:!0,writable:!0},attr0:{value:function(e,...t){return typeof this!="object"?this:typeof e=="function"?e(this,...t):this[e]},enumerable:!1,configurable:!0,writable:!0},log0:{value:function(...e){return console.log(...e,this),this},enumerable:!1,configurable:!0,writable:!0},debug0:{value:function(...e){return console.debug(...e,this),this},enumerable:!1,configurable:!0,writable:!0},getParents0:{value:function(e=!1,t=-1,r="parent"){const u=e?[this]:[];let n=this[r];for(;n&&t--!=0;)u.push(n),n=n[r];return u},enumerable:!1,configurable:!0,writable:!0},getChildrens0:{value:function(e=!1,t=-1,r="children"){const u=[],n=(l,a,f)=>{if(a&&u.push(l),!(f==0||!l[r]||l[r].length==0))for(const o of l[r])n(o,!0,f-1)};return n(this,e,t),u},enumerable:!1,configurable:!0,writable:!0},treeFind0:{value:function(e,t=!0,r=-1,u="children"){if(t&&e(this))return this;if(r==0||!this[u]||this[u].length==0)return null;for(const n of this[u]){const l=n.treeFind0(e,!0,r-1,u);if(l!==null)return l}return null},enumerable:!1,configurable:!0,writable:!0},treeEach0:{value:function(e,t=!0,r=-1,u="children"){if(t&&e(this),!(r==0||!this[u]||this[u].length==0)){for(const n of this[u])n.treeEach0(e,!0,r-1,u);return this}},enumerable:!1,configurable:!0,writable:!0},treeMap0:{value:function(e,t=!0,r=-1,u="children",n=null){const l=t?e(this):this,a=[];if(r==0||!this[u]||this[u].length==0)return l;for(const f of this[u])a.push(f.treeMap0(e,!0,r-1,u,n));return l[u]=a,l},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Number.prototype,{ceil:{value:function(){return Math.ceil(this)},enumerable:!1,configurable:!0,writable:!0},floor:{value:function(){return Math.floor(this)},enumerable:!1,configurable:!0,writable:!0},round:{value:function(e=0){return e==0?Math.round(this):Math.round(this*10**e)/10**e},enumerable:!1,configurable:!0,writable:!0},trunc:{value:function(){return Math.trunc(this)},enumerable:!1,configurable:!0,writable:!0},abs:{value:function(){return Math.abs(this)},enumerable:!1,configurable:!0,writable:!0},max:{value:function(...e){return Math.max(this,...e)},enumerable:!1,configurable:!0,writable:!0},min:{value:function(...e){return Math.min(this,...e)},enumerable:!1,configurable:!0,writable:!0},baseConvert:{value:function(e=64){let t="",r=this,u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;r>0;)t=u.at(r%e)+t,r=Math.floor(r/e);return t||"0"},enumerable:!1,configurable:!0,writable:!0},toFixed0:{value:function(...e){return+this.toFixed(...e)},enumerable:!1,configurable:!0,writable:!0},toDate:{value:function(){return Date.new(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(BigInt.prototype,{toJSON:{value:function(){return this>9007199254740991n||this<-9007199254740991n?this.toString():Number(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(String.prototype,{length0:{value:function(){return this.length},enumerable:!1,configurable:!0,writable:!0},substring0:{value:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=t>=0?t:this.length+t,this.substring(e,t)},enumerable:!1,configurable:!0,writable:!0},substr0:{value:function(e=0,t=this.length){return e=e>=0?e:this.length+e,t=e+t,this.substring(e,t)},enumerable:!1,configurable:!0,writable:!0},split0:{value:function(e=",",t=-1){const r=this?this.split(e):[];return t===-1?r:r.push0(r.splice(t-1).join(e))},enumerable:!1,configurable:!0,writable:!0},splitNumber:{value:function(e=","){return this.split0(e).map(t=>+t)},enumerable:!1,configurable:!0,writable:!0},splitSegment:{value:function(e=1){const t=[];for(let r=0;r<this.length;r+=e)t.push(this.substring(r,e));return t},enumerable:!1,configurable:!0,writable:!0},sprintf:{value:function(...e){let[t,...r]=this.split(/%[sd]/);for(let u=0;u<r.length;u++)t+=e[u]+r[u];return t},enumerable:!1,configurable:!0,writable:!0},subOf:{value:function(e,t,r=0,u=0){for(let a=0;a<r&&u!=-1;a++,u++)u=this.indexOf(e,u);let n=this.indexOf(e,u),l=this.indexOf(t,n);return n==-1||l==-1?"":(n+=e.length,this.substring(n,l))},enumerable:!1,configurable:!0,writable:!0},lastSubOf:{value:function(e,t,r=0,u=1/0){for(let a=0;a<r&&u!=-1;a++,u--)u=this.lastIndexOf(e,u);let n=this.lastIndexOf(e,u),l=this.indexOf(t,n);return n==-1||l==-1?"":(n+=e.length,this.substring(n,l))},enumerable:!1,configurable:!0,writable:!0},camel2under:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1).replace(/([A-Z])/g,(e,t)=>"_"+t.toLowerCase())},enumerable:!1,configurable:!0,writable:!0},under2camel:{value:function(){return this.replace(/_([a-z])/g,(e,t)=>t.toUpperCase())},enumerable:!1,configurable:!0,writable:!0},camel2pascal:{value:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},enumerable:!1,configurable:!0,writable:!0},pascal2camel:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},enumerable:!1,configurable:!0,writable:!0},under2kebab:{value:function(){return this.replace(/_/g,"-")},enumerable:!1,configurable:!0,writable:!0},kebab2under:{value:function(){return this.replace(/-/g,"_")},enumerable:!1,configurable:!0,writable:!0},baseConvert:{value:function(e=64){let t=0,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let u=0;u<this.length;u++)t=t*e+r.indexOf(this.at(u));return t},enumerable:!1,configurable:!0,writable:!0},toFixed0:{value:function(...e){return+(+this).toFixed(...e)},enumerable:!1,configurable:!0,writable:!0},toDate:{value:function(){return Date.new(this)},enumerable:!1,configurable:!0,writable:!0},hex2bytes:{value:function(){const e=[];for(let t=0;t<this.length;t+=2)e.push(Number.parseInt(this.substring(t,t+2),16));return e},enumerable:!1,configurable:!0,writable:!0},string2bytes:{value:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const e=[],t=encodeURIComponent(this);for(let r=0;r<t.length;)e.push(t.charAt(r)=="%"?Number.parseInt(t.substring(r+1,r+=3),16):t.charCodeAt(r++));return e},enumerable:!1,configurable:!0,writable:!0},base64decode:{value:function(e){const t=[],r={},u=e===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let l=0;l<u.length;l++)r[u.charAt(l)]=l;const n=this.charAt(this.length-1)!="="?this.length:this.charAt(this.length-2)!="="?this.length-1:this.length-2;for(let l=3;l<n;l+=4){const a=(r[this.charAt(l-3)]<<18)+(r[this.charAt(l-2)]<<12)+(r[this.charAt(l-1)]<<6)+r[this.charAt(l)];t.push((a&16711680)>>16,(a&65280)>>8,a&255)}if(n%4==3){const l=(r[this.charAt(n-3)]<<18)+(r[this.charAt(n-2)]<<12)+(r[this.charAt(n-1)]<<6);t.push((l&16711680)>>16,(l&65280)>>8)}else if(n%4==2){const l=(r[this.charAt(n-2)]<<18)+(r[this.charAt(n-1)]<<12);t.push((l&16711680)>>16)}return t},enumerable:!1,configurable:!0,writable:!0}}),typeof Iterator<"u"&&Object.defineProperties(Iterator.prototype,{toArray:{value:function(){return Array.from(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Array.prototype,{length0:{value:function(){return this.length},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return this.entries()},enumerable:!1,configurable:!0,writable:!0},push0:{value:function(...e){return this.push(...e),this},enumerable:!1,configurable:!0,writable:!0},push1:{value:function(...e){return this.push(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},push3:{value:function(...e){return this.push(...e),e},enumerable:!1,configurable:!0,writable:!0},pop0:{value:function(...e){return this.pop(...e),this},enumerable:!1,configurable:!0,writable:!0},pop1:{value:function(...e){return this.pop(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},pop3:{value:function(...e){return this.pop(...e),e},enumerable:!1,configurable:!0,writable:!0},unshift0:{value:function(...e){return this.unshift(...e),this},enumerable:!1,configurable:!0,writable:!0},unshift1:{value:function(...e){return this.unshift(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},unshift3:{value:function(...e){return this.unshift(...e),e},enumerable:!1,configurable:!0,writable:!0},shift0:{value:function(...e){return this.shift(...e),this},enumerable:!1,configurable:!0,writable:!0},shift1:{value:function(...e){return this.shift(...e),e[0]},enumerable:!1,configurable:!0,writable:!0},shift3:{value:function(...e){return this.shift(...e),e},enumerable:!1,configurable:!0,writable:!0},first0:{value:function(e=null){return this.length?this[0]:e},enumerable:!1,configurable:!0,writable:!0},last0:{value:function(e=null){return this.length?this[this.length-1]:e},enumerable:!1,configurable:!0,writable:!0},find0:{value:function(e,t=null){return this.find(e)??t},enumerable:!1,configurable:!0,writable:!0},equals0:{value:function(e){return this.length===e.length&&(this===e||this.length===0||this.every((t,r)=>t===e[r]))},enumerable:!1,configurable:!0,writable:!0},unique0:{value:function(e=t=>t){const t=new Set;return this.filter(r=>t.has(e(r))?!1:!!t.add(e(r)))},enumerable:!1,configurable:!0,writable:!0},each0:{value:function(e){return this.forEach(e),this},enumerable:!1,configurable:!0,writable:!0},toObject:{value:function(e=(t,r)=>[r,t]){return Object.fromEntries(this.map(e))},enumerable:!1,configurable:!0,writable:!0},toMap:{value:function(e=(t,r)=>[r,t]){return new Map(this.map(e))},enumerable:!1,configurable:!0,writable:!0},toSet:{value:function(){return new Set(this)},enumerable:!1,configurable:!0,writable:!0},toGroup:{value:function(e=t=>[t.id,t]){const t={};for(const r of this){const[u,n]=e(r);u in t||(t[u]=[]),t[u].push(n)}return t},enumerable:!1,configurable:!0,writable:!0},toMerge:{value:function(e=u=>u.id,t=u=>({...u,children:u.children||[]}),r=(u,n)=>u.children.push(n)){const u=[];for(const n of this)r(u.find(l=>e(l)==e(n))??u.push1(t(n)),n);return u},enumerable:!1,configurable:!0,writable:!0},bytes2hex:{value:function(){let e="";for(let t=0;t<this.length;t++)e+=(this[t]<16?"0":"")+this[t].toString(16);return e},enumerable:!1,configurable:!0,writable:!0},bytes2string:{value:function(){if(typeof TextDecoder<"u")return new TextDecoder().decode(new Uint8Array(this));let e="";for(let t=0;t<this.length;t++)e+="%"+(this[t]<16?"0":"")+this[t].toString(16);return decodeURIComponent(e)},enumerable:!1,configurable:!0,writable:!0},base64encode:{value:function(e=!1,t=!0){let r="",u=e===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const l=(this[n-2]<<16)+(this[n-1]<<8)+this[n];r+=u.charAt((l&16515072)>>18)+u.charAt((l&258048)>>12)+u.charAt((l&4032)>>6)+u.charAt(l&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);r+=u.charAt((n&16515072)>>18)+u.charAt((n&258048)>>12)+u.charAt((n&4032)>>6)+(t===!1?"":"=")}else if(this.length%3==1){const n=this[this.length-1]<<16;r+=u.charAt((n&16515072)>>18)+u.charAt((n&258048)>>12)+(t===!1?"":"==")}return r},enumerable:!1,configurable:!0,writable:!0},toUint8Array:{value:function(){return new Uint8Array(this)},enumerable:!1,configurable:!0,writable:!0},assoc:{value:function(e,t,r={}){const u=this.unique0(l=>l[e]),n=u.length==0?{}:typeof r=="function"?r(u):r;return this.each0(l=>l[t]=n[l[e]]??null)},enumerable:!1,configurable:!0,writable:!0},toTree:{value:function(e={}){const{id:t="id",pid:r="pid",level:u="level",root:n="root",parent:l="parent",children:a="children",empty:f=null,hasRoot:o=!0}=e,h=this.toObject(i=>[i[t],i]),c=this.toGroup(i=>[i[r],i]),s=this.length&&o?this.find(i=>i[r]===0):{[t]:0,[r]:-1,[n]:null,[l]:null,[a]:c[0]};Object.defineProperties(s,{[n]:{value:s,enumerable:!1,configurable:!0,writable:!0}});for(const i of this)Object.defineProperties(i,{[n]:{value:s,enumerable:!1,configurable:!0,writable:!0},[l]:{value:h[i[r]],enumerable:!1,configurable:!0,writable:!0}}),i[a]=c[i[t]]??f;return s.treeEach0(i=>i[u]=i[l]?i[l][u]+1:0,-1,a),s},enumerable:!1,configurable:!0,writable:!0},tree2tree:{value:function(e={},t=null,r=null){var c;const{id:u="id",pid:n="pid",level:l="level",root:a="root",parent:f="parent",children:o="children",empty:h=null}=e;t=t??{[u]:0,[n]:-1,[l]:0,[a]:null,[f]:null,[o]:this},r=r??t;for(const s of this)Object.defineProperties(s,{[a]:{value:t,enumerable:!1,configurable:!0,writable:!0},[f]:{value:r,enumerable:!1,configurable:!0,writable:!0}}),s[n]=r[u],s[l]=r[l]+1,s[o]=s[o]&&s[o].length?s[o]:h,(c=s[o])==null||c.tree2tree(e,t,s);return t},enumerable:!1,configurable:!0,writable:!0},treeFind0:{value:function(e,t=!0,r=-1,u="children"){for(const n of this){const l=n.treeFind0(e,t,r,u);if(l!==null)return l}return null},enumerable:!1,configurable:!0,writable:!0},treeEach0:{value:function(e,t=!0,r=-1,u="children"){for(const n of this)n.treeEach0(e,t,r,u);return this},enumerable:!1,configurable:!0,writable:!0},treeMap0:{value:function(e,t=!0,r=-1,u="children",n=null){return this.map(l=>l.treeMap0(e,t,r,u,n))},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(ArrayBuffer.prototype,{toUint8Array:{value:function(){return new Uint8Array(this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Uint8Array.prototype,{bytes2hex:{value:Array.prototype.bytes2hex,enumerable:!1,configurable:!0,writable:!0},bytes2string:{value:Array.prototype.bytes2string,enumerable:!1,configurable:!0,writable:!0},base64encode:{value:Array.prototype.base64encode,enumerable:!1,configurable:!0,writable:!0},toArray:{value:function(){return new Array(...this)},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Map.prototype,{length0:{value:function(){return this.size},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return[...this.entries()]},enumerable:!1,configurable:!0,writable:!0},keys0:{value:function(){return[...this.keys()]},enumerable:!1,configurable:!0,writable:!0},values0:{value:function(){return[...this.values()]},enumerable:!1,configurable:!0,writable:!0},get0:{value:function(e,t=null,...r){if(this.has(e))return this.get(e);const u=typeof t!="function"?t:t(e,...r);return this.set(e,u),u},enumerable:!1,configurable:!0,writable:!0},get1:{value:async function(e,t=null,...r){if(this.has(e))return this.get(e);const u=typeof t!="function"?t:await t(e,...r);return this.set(e,u),u},enumerable:!1,configurable:!0,writable:!0},toObject:{value:function(){return Object.fromEntries(this)},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Set.prototype,{length0:{value:function(){return this.size},enumerable:!1,configurable:!0,writable:!0},entries0:{value:function(){return this.entries()},enumerable:!1,configurable:!0,writable:!0},toArray:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return[...this]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Date,{new:{value:function(...e){return e.length!=1?new Date(...e):Number.isNaN(+e[0])?new Date(e[0].includes("T")?e[0]:e[0].replace(/-/g,"/")):new Date(e[0]>25e8?e[0]:e[0]*1e3)},enumerable:!1,configurable:!0,writable:!0},format:{value:function(e="y-m-d h:i:s"){return new Date().format(e)},enumerable:!1,configurable:!0,writable:!0},unix:{value:function(){return this.now()/1e3|0},enumerable:!1,configurable:!0,writable:!0},fromUnix:{value:function(e=0){return this.new((e||0)*1e3)},enumerable:!1,configurable:!0,writable:!0},expr:{value:function(e={}){return new Date().expr(e)},enumerable:!1,configurable:!0,writable:!0},toDayRange:{value:function(){const e=new Date,t=e.getFullYear(),r=e.getMonth(),u=e.getDate(),n=new Date(t,r,u).getTime()/1e3|0;return[n,n+86400-1]},enumerable:!1,configurable:!0,writable:!0},toWeekRange:{value:function(){let e=new Date;for(;e.getDay()!=1;)e=new Date(e.getTime()-86400);const t=e.getFullYear(),r=e.getMonth(),u=e.getDate(),n=new Date(t,r,u).getTime()/1e3|0;return[n,n+86400*7-1]},enumerable:!1,configurable:!0,writable:!0},toMonthRange:{value:function(){const e=new Date,t=e.getFullYear(),r=e.getMonth(),u=new Date(t,r,1).getTime()/1e3|0,n=new Date(t,r+1,0,23,59,59).getTime()/1e3|0;return[u,n]},enumerable:!1,configurable:!0,writable:!0},toYearRange:{value:function(){const t=new Date().getFullYear(),r=new Date(t,1,1).getTime()/1e3|0,u=new Date(t+1,1,0,23,59,59).getTime()/1e3|0;return[r,u]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Date.prototype,{format:{value:function(e="y-m-d h:i:s"){if(this.getTime()===0)return"-";const t={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return e.replace(/([ymdhisle])/ig,(r,u)=>u>="A"&&u<="Z"?t[u.toLowerCase()]:t[u].toString().padStart(u==="l"?3:2,"0"))},enumerable:!1,configurable:!0,writable:!0},unix:{value:function(){return this.getTime()/1e3|0},enumerable:!1,configurable:!0,writable:!0},isLeapYear:{value:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},enumerable:!1,configurable:!0,writable:!0},getMonthDay:{value:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},enumerable:!1,configurable:!0,writable:!0},expr:{value:function({y:e=0,m:t=0,d:r=0,h:u=0,i:n=0,s:l=0}){const a=new Date(this.getFullYear()+e,this.getMonth()+t+1,0);return new Date(this.getFullYear()+e,this.getMonth()+t,Math.min(a.getDate(),this.getDate())+r,this.getHours()+u,this.getMinutes()+n,this.getSeconds()+l)},enumerable:!1,configurable:!0,writable:!0},begin:{value:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),0,1,0,0,0].slice(e))},enumerable:!1,configurable:!0,writable:!0},end:{value:function(e=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,e),...[this.getFullYear(),11,e<2?31:this.getMonthDay(),23,59,59].slice(e))},enumerable:!1,configurable:!0,writable:!0},week:{value:function(e,t=1){let r=new Date(this.getTime());for(;r.getDay()!==e;)r=new Date(r.getTime()+864e5*t);return r},enumerable:!1,configurable:!0,writable:!0},toJSON:{value:function(){return this.getTime()},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(RegExp.prototype,{toJSON:{value:function(){return this.toString()},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Promise.prototype,{tryCatch:{value:function(){return new Promise(e=>this.then(t=>e([t,null])).catch(t=>e([null,t])))},enumerable:!1,configurable:!0,writable:!0}}),typeof Promise.withResolvers>"u"&&Object.defineProperties(Promise,{withResolvers:{value:function(){let e=null,t=null;return{promise:new this((u,n)=>{e=u,t=n}),resolve:e,reject:t}},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(Promise,{channel:{value:function(){let e=null,t=null;return[new this((u,n)=>{e=u,t=n}),e,t]},enumerable:!1,configurable:!0,writable:!0}}),Object.defineProperties(JSON,{parse0:{value:function(e,t=null){try{if(typeof e!="string")throw new Error("not string");return JSON.parse(e)}catch{return t}},enumerable:!1,configurable:!0,writable:!0}})});
1
+ (function(l){typeof define=="function"&&define.amd?define(l):l()})(function(){"use strict";const l=Object.defineProperties,n={enumerable:!1,configurable:!0,writable:!0};function p(t={array:!1}){return function(e={},...r){const u=(i,s)=>{const o=Object.prototype.toString.call(i),f=Object.prototype.toString.call(s);if(o!==f)return s;if(o==="[object Array]")return t.array?i.concat(...s):s;if(o==="[object Object]"){for(const c in s)i[c]=u(i[c],s[c]);return i}else return s};for(const i of r)e=u(e,i);return e}}const d=p({array:!1}),b=p({array:!0});l(Object,{isObject:{value:function(t){return Object.prototype.toString.call(t)==="[object Object]"},...n},merge0:{value:function(...t){return d(this,...t)},...n},concat0:{value:function(...t){return b(this,...t)},...n}}),l(Object.prototype,{clone0:{value:function(){return JSON.parse(JSON.stringify(this))},...n},length0:{value:function(){return Object.keys(this).length},...n},entries0:{value:function(){return Object.entries(this)},...n},keys0:{value:function(){return Object.keys(this)},...n},values0:{value:function(){return Object.values(this)},...n},merge0:{value:function(...t){return d(this,...t)},...n},concat0:{value:function(...t){return b(this,...t)},...n},map0:{value:function(t=(r,u,i)=>[r,u],e=0){return Object.entries(this).map(([r,u])=>t(r,u,e++))},...n},pick0:{value:function(...t){const e={};for(const r of t)e[r]=this[r];return e},...n},omit0:{value:function(...t){const e={},r=new Set(t);for(const u in this)r.has(u)||(e[u]=this[u]);return e},...n},attr0:{value:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):this[t]},...n},log0:{value:function(...t){return console.log(...t,this),this},...n},debug0:{value:function(...t){return console.debug(...t,this),this},...n},getParents0:{value:function(t=!1,e=-1,r="parent"){const u=t?[this]:[];let i=this[r];for(;i&&e--!=0;)u.push(i),i=i[r];return u},...n},getChildrens0:{value:function(t=!1,e=-1,r="children"){const u=[],i=(s,o,f)=>{if(o&&u.push(s),!(f==0||!s[r]||s[r].length==0))for(const c of s[r])i(c,!0,f-1)};return i(this,t,e),u},...n},treeFind0:{value:function(t,e=!0,r=-1,u="children"){if(e&&t(this))return this;if(r==0||!this[u]||this[u].length==0)return null;for(const i of this[u]){const s=i.treeFind0(t,!0,r-1,u);if(s!==null)return s}return null},...n},treeEach0:{value:function(t,e=!0,r=-1,u="children"){if(e&&t(this),!(r==0||!this[u]||this[u].length==0)){for(const i of this[u])i.treeEach0(t,!0,r-1,u);return this}},...n},treeMap0:{value:function(t,e=!0,r=-1,u="children",i=null){const s=e?t(this):this,o=[];if(r==0||!this[u]||this[u].length==0)return s;for(const f of this[u])o.push(f.treeMap0(t,!0,r-1,u,i));return s[u]=o,s},...n}}),l(Number.prototype,{ceil:{value:function(){return Math.ceil(this)},...n},floor:{value:function(){return Math.floor(this)},...n},round:{value:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},...n},trunc:{value:function(){return Math.trunc(this)},...n},abs:{value:function(){return Math.abs(this)},...n},max:{value:function(...t){return Math.max(this,...t)},...n},min:{value:function(...t){return Math.min(this,...t)},...n},baseConvert:{value:function(t=64){let e="",r=this,u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;r>0;)e=u.at(r%t)+e,r=Math.floor(r/t);return e||"0"},...n},toFixed0:{value:function(...t){return+this.toFixed(...t)},...n},toDate:{value:function(){return Date.new(this)},...n}}),l(BigInt.prototype,{toJSON:{value:function(){return this>9007199254740991n||this<-9007199254740991n?this.toString():Number(this)},...n}}),l(String.prototype,{length0:{value:function(){return this.length},...n},substring0:{value:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},...n},substr0:{value:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},...n},split0:{value:function(t=",",e=-1){const r=this?this.split(t):[];return e===-1?r:r.push0(r.splice(e-1).join(t))},...n},splitNumber:{value:function(t=","){return this.split0(t).map(e=>+e)},...n},splitSegment:{value:function(t=1){const e=[];for(let r=0;r<this.length;r+=t)e.push(this.substring(r,t));return e},...n},sprintf:{value:function(...t){let[e,...r]=this.split(/%[sd]/);for(let u=0;u<r.length;u++)e+=t[u]+r[u];return e},...n},subOf:{value:function(t,e,r=0,u=0){for(let o=0;o<r&&u!=-1;o++,u++)u=this.indexOf(t,u);let i=this.indexOf(t,u),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},...n},lastSubOf:{value:function(t,e,r=0,u=1/0){for(let o=0;o<r&&u!=-1;o++,u--)u=this.lastIndexOf(t,u);let i=this.lastIndexOf(t,u),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},...n},camel2under:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},...n},under2camel:{value:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},...n},camel2pascal:{value:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},...n},pascal2camel:{value:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},...n},under2kebab:{value:function(){return this.replace(/_/g,"-")},...n},kebab2under:{value:function(){return this.replace(/-/g,"_")},...n},baseConvert:{value:function(t=64){let e=0,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let u=0;u<this.length;u++)e=e*t+r.indexOf(this.at(u));return e},...n},toFixed0:{value:function(...t){return+(+this).toFixed(...t)},...n},toDate:{value:function(){return Date.new(this)},...n},hex2bytes:{value:function(){const t=[];for(let e=0;e<this.length;e+=2)t.push(Number.parseInt(this.substring(e,e+2),16));return t},...n},string2bytes:{value:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const t=[],e=encodeURIComponent(this);for(let r=0;r<e.length;)t.push(e.charAt(r)=="%"?Number.parseInt(e.substring(r+1,r+=3),16):e.charCodeAt(r++));return t},...n},base64decode:{value:function(t){const e=[],r={},u=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let s=0;s<u.length;s++)r[u.charAt(s)]=s;const i=this.charAt(this.length-1)!="="?this.length:this.charAt(this.length-2)!="="?this.length-1:this.length-2;for(let s=3;s<i;s+=4){const o=(r[this.charAt(s-3)]<<18)+(r[this.charAt(s-2)]<<12)+(r[this.charAt(s-1)]<<6)+r[this.charAt(s)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(i%4==3){const s=(r[this.charAt(i-3)]<<18)+(r[this.charAt(i-2)]<<12)+(r[this.charAt(i-1)]<<6);e.push((s&16711680)>>16,(s&65280)>>8)}else if(i%4==2){const s=(r[this.charAt(i-2)]<<18)+(r[this.charAt(i-1)]<<12);e.push((s&16711680)>>16)}return e},...n}}),typeof Iterator<"u"&&l(Iterator.prototype,{toArray:{value:function(){return Array.from(this)},...n}}),l(Array.prototype,{length0:{value:function(){return this.length},...n},entries0:{value:function(){return this.entries()},...n},push0:{value:function(...t){return this.push(...t),this},...n},push1:{value:function(...t){return this.push(...t),t[0]},...n},push3:{value:function(...t){return this.push(...t),t},...n},pop0:{value:function(...t){return this.pop(...t),this},...n},pop1:{value:function(...t){return this.pop(...t),t[0]},...n},pop3:{value:function(...t){return this.pop(...t),t},...n},unshift0:{value:function(...t){return this.unshift(...t),this},...n},unshift1:{value:function(...t){return this.unshift(...t),t[0]},...n},unshift3:{value:function(...t){return this.unshift(...t),t},...n},shift0:{value:function(...t){return this.shift(...t),this},...n},shift1:{value:function(...t){return this.shift(...t),t[0]},...n},shift3:{value:function(...t){return this.shift(...t),t},...n},first0:{value:function(t=null){return this.length?this[0]:t},...n},last0:{value:function(t=null){return this.length?this[this.length-1]:t},...n},find0:{value:function(t,e=null){return this.find(t)??e},...n},equals0:{value:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,r)=>e===t[r]))},...n},unique0:{value:function(t=e=>e){const e=new Set;return this.filter(r=>e.has(t(r))?!1:!!e.add(t(r)))},...n},each0:{value:function(t){return this.forEach(t),this},...n},toObject:{value:function(t=(e,r)=>[r,e]){return Object.fromEntries(this.map(t))},...n},toMap:{value:function(t=(e,r)=>[r,e]){return new Map(this.map(t))},...n},toSet:{value:function(){return new Set(this)},...n},toGroup:{value:function(t=e=>[e.id,e]){const e={};for(const r of this){const[u,i]=t(r);u in e||(e[u]=[]),e[u].push(i)}return e},...n},toMerge:{value:function(t=u=>u.id,e=u=>({...u,children:u.children||[]}),r=(u,i)=>u.children.push(i)){const u=[];for(const i of this)r(u.find(s=>t(s)==t(i))??u.push1(e(i)),i);return u},...n},bytes2hex:{value:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},...n},bytes2string:{value:function(){if(typeof TextDecoder<"u")return new TextDecoder().decode(new Uint8Array(this));let t="";for(let e=0;e<this.length;e++)t+="%"+(this[e]<16?"0":"")+this[e].toString(16);return decodeURIComponent(t)},...n},base64encode:{value:function(t=!1,e=!0){let r="",u=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let i=2;i<this.length;i+=3){const s=(this[i-2]<<16)+(this[i-1]<<8)+this[i];r+=u.charAt((s&16515072)>>18)+u.charAt((s&258048)>>12)+u.charAt((s&4032)>>6)+u.charAt(s&63)}if(this.length%3==2){const i=(this[this.length-2]<<16)+(this[this.length-1]<<8);r+=u.charAt((i&16515072)>>18)+u.charAt((i&258048)>>12)+u.charAt((i&4032)>>6)+(e===!1?"":"=")}else if(this.length%3==1){const i=this[this.length-1]<<16;r+=u.charAt((i&16515072)>>18)+u.charAt((i&258048)>>12)+(e===!1?"":"==")}return r},...n},toUint8Array:{value:function(){return new Uint8Array(this)},...n},assoc:{value:function(t,e,r={}){const u=this.unique0(s=>s[t]),i=u.length==0?{}:typeof r=="function"?r(u):r;return this.each0(s=>s[e]=i[s[t]]??null)},...n},toTree:{value:function(t={}){const{id:e="id",pid:r="pid",level:u="level",root:i="root",parent:s="parent",children:o="children",empty:f=null,hasRoot:c=!0}=t,v=this.toObject(h=>[h[e],h]),g=this.toGroup(h=>[h[r],h]),a=this.length&&c?this.find(h=>h[r]===0):{[e]:0,[r]:-1,[i]:null,[s]:null,[o]:g[0]};l(a,{[i]:{value:a,enumerable:!1,configurable:!0,writable:!0}});for(const h of this)l(h,{[i]:{value:a,enumerable:!1,configurable:!0,writable:!0},[s]:{value:v[h[r]],enumerable:!1,configurable:!0,writable:!0}}),h[o]=g[h[e]]??f;return a.treeEach0(h=>h[u]=h[s]?h[s][u]+1:0,-1,o),a},...n},tree2tree:{value:function(t={},e=null,r=null){var g;const{id:u="id",pid:i="pid",level:s="level",root:o="root",parent:f="parent",children:c="children",empty:v=null}=t;e=e??{[u]:0,[i]:-1,[s]:0,[o]:null,[f]:null,[c]:this},r=r??e;for(const a of this)l(a,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[f]:{value:r,enumerable:!1,configurable:!0,writable:!0}}),a[i]=r[u],a[s]=r[s]+1,a[c]=a[c]&&a[c].length?a[c]:v,(g=a[c])==null||g.tree2tree(t,e,a);return e},...n},treeFind0:{value:function(t,e=!0,r=-1,u="children"){for(const i of this){const s=i.treeFind0(t,e,r,u);if(s!==null)return s}return null},...n},treeEach0:{value:function(t,e=!0,r=-1,u="children"){for(const i of this)i.treeEach0(t,e,r,u);return this},...n},treeMap0:{value:function(t,e=!0,r=-1,u="children",i=null){return this.map(s=>s.treeMap0(t,e,r,u,i))},...n}}),l(ArrayBuffer.prototype,{toUint8Array:{value:function(){return new Uint8Array(this)},...n}}),l(Uint8Array.prototype,{bytes2hex:{value:Array.prototype.bytes2hex,...n},bytes2string:{value:Array.prototype.bytes2string,...n},base64encode:{value:Array.prototype.base64encode,...n},toArray:{value:function(){return new Array(...this)},...n}}),l(Map.prototype,{length0:{value:function(){return this.size},...n},entries0:{value:function(){return[...this.entries()]},...n},keys0:{value:function(){return[...this.keys()]},...n},values0:{value:function(){return[...this.values()]},...n},get0:{value:function(t,e=null,...r){if(this.has(t))return this.get(t);const u=typeof e!="function"?e:e(t,...r);return this.set(t,u),u},...n},get1:{value:async function(t,e=null,...r){if(this.has(t))return this.get(t);const u=typeof e!="function"?e:await e(t,...r);return this.set(t,u),u},...n},toObject:{value:function(){return Object.fromEntries(this)},...n},toJSON:{value:function(){return[...this]},...n}}),l(Set.prototype,{length0:{value:function(){return this.size},...n},entries0:{value:function(){return this.entries()},...n},toArray:{value:function(){return[...this]},...n},toJSON:{value:function(){return[...this]},...n}}),l(Date,{new:{value:function(...t){return t.length!=1?new Date(...t):Number.isNaN(+t[0])?new Date(t[0].includes("T")?t[0]:t[0].replace(/-/g,"/")):new Date(t[0]>25e8?t[0]:t[0]*1e3)},...n},format:{value:function(t="y-m-d h:i:s"){return new Date().format(t)},...n},unix:{value:function(){return this.now()/1e3|0},...n},fromUnix:{value:function(t=0){return this.new((t||0)*1e3)},...n},expr:{value:function(t={}){return new Date().expr(t)},...n},toDayRange:{value:function(){const t=new Date,e=t.getFullYear(),r=t.getMonth(),u=t.getDate(),i=new Date(e,r,u).getTime()/1e3|0;return[i,i+86400-1]},...n},toWeekRange:{value:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),r=t.getMonth(),u=t.getDate(),i=new Date(e,r,u).getTime()/1e3|0;return[i,i+86400*7-1]},...n},toMonthRange:{value:function(){const t=new Date,e=t.getFullYear(),r=t.getMonth(),u=new Date(e,r,1).getTime()/1e3|0,i=new Date(e,r+1,0,23,59,59).getTime()/1e3|0;return[u,i]},...n},toYearRange:{value:function(){const e=new Date().getFullYear(),r=new Date(e,1,1).getTime()/1e3|0,u=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[r,u]},...n}}),l(Date.prototype,{format:{value:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return t.replace(/([ymdhisle])/ig,(r,u)=>u>="A"&&u<="Z"?e[u.toLowerCase()]:e[u].toString().padStart(u==="l"?3:2,"0"))},...n},unix:{value:function(){return this.getTime()/1e3|0},...n},isLeapYear:{value:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},...n},getMonthDay:{value:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},...n},expr:{value:function({y:t=0,m:e=0,d:r=0,h:u=0,i=0,s=0}){const o=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(o.getDate(),this.getDate())+r,this.getHours()+u,this.getMinutes()+i,this.getSeconds()+s)},...n},begin:{value:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),0,1,0,0,0].slice(t))},...n},end:{value:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),11,t<2?31:this.getMonthDay(),23,59,59].slice(t))},...n},week:{value:function(t,e=1){let r=new Date(this.getTime());for(;r.getDay()!==t;)r=new Date(r.getTime()+864e5*e);return r},...n},toJSON:{value:function(){return this.getTime()},...n}}),l(RegExp.prototype,{toJSON:{value:function(){return this.toString()},...n}}),l(Promise.prototype,{tryCatch:{value:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))},...n}}),typeof Promise.withResolvers>"u"&&l(Promise,{withResolvers:{value:function(){let t=null,e=null;return{promise:new this((u,i)=>{t=u,e=i}),resolve:t,reject:e}},...n}}),l(Promise,{channel:{value:function(){let t=null,e=null;return[new this((u,i)=>{t=u,e=i}),t,e]},...n}}),l(JSON,{parse0:{value:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}},...n}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esexts",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "esexts",
5
5
  "author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
6
6
  "homepage": "https://github.com/dotcoo/esexts#readme",