tools_dj 1.0.40 → 1.0.41
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/lib/index.d.ts +5 -0
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t){let e={};return t.forEach((function(t){e[JSON.stringify(t)]=t})),t=Object.keys(e).map((function(t){if("undefined"!=t)return JSON.parse(t)}))}function e(t){let e=!1;switch(Object.prototype.toString.call(t).slice(8,-1)){case"Undefined":case"Null":e=!0;break;case"String":e=0===t.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g,"").length;break;case"Boolean":e=!t;break;case"Array":e=0===t.length;break;case"Number":e=0===t||isNaN(t);break;case"Object":e=0===Object.keys(t).length}return e}function r(t){return Object.prototype.toString.call(t).slice(8,-1)}function n(){return!e(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))}function o(t,e){return Math.round(Math.random()*(e-t))+t}function c(t){let e=Number(t);return!isNaN(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.auth=void 0,exports.del_repeat=t,exports.formatDate=function(t,e="day",r="-"){let n=t.getFullYear(),o=(t.getMonth()+1).toString().padStart(2,"0"),c=t.getDate().toString().padStart(2,"0"),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0"),a={year:1,month:2,day:3,hour:4,minute:5},u="";for(let t=0;t<a[e];t++)0==t&&(u+=n),1==t&&(u+=o),2==t&&(u+=c),3==t&&(u+=i),4==t&&(u+=s),t!=a[e]-1&&(u+=r);return u},exports.time_change=function(t){return Date.parse(t)},exports.formatTime=function(t,e="YYYY-MM-DD hh:mm:ss",n="-"){var o;try{t=t.replaceAll("-","/")}catch(t){}let c=(t=new Date(t)).getFullYear(),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=t.getHours().toString().padStart(2,"0"),u=t.getMinutes().toString().padStart(2,"0"),l=t.getSeconds().toString().padStart(2,"0"),p={0:"周日",1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六"}[t.getDay()],f=a>12?"下午":"上午",d=[];d=[{group:1,connect:"Object"==r(n)&&null!==(o=n.YYYY)&&void 0!==o?o:"",format:"YYYY",data:c},{group:1,connect:"",format:"yyyy",data:c},{group:1,connect:n,format:"MM",data:i},{group:1,connect:n,format:"DD",data:s},{group:1,connect:n,format:"dd",data:s},{group:2,connect:" ",format:"hh",data:a},{group:2,connect:" ",format:"HH",data:a},{group:2,connect:":",format:"mm",data:u},{group:2,connect:":",format:"ss",data:l},{group:3,connect:" ",format:"week",data:p},{group:4,connect:" ",format:"time_slot",data:f}];let h=0,g="";return d.forEach((function(t,r){if(-1!=e.indexOf(t.format)){let e="";0!=h&&(e=t.connect),g+=e+t.data,h++}})),g},exports.getDaysBetween=function(t,e,r=!1){var n=Date.parse(t),o=Date.parse(e),c=0;n>o&&(c=(n-o)/864e5);n<o&&(c=(o-n)/864e5,r&&(c=-c));return c},exports.is_empty=e,exports.repalce=function(t,e,r){return t.substring(0,e)+r+t.substring(e+1)},exports.param=function(t,r=!0){if(0==e(t)){let e=r?"?":"",n=[];for(let e in t){let r=t[e];["",void 0,null].includes(r)||(r.constructor===Array?r.forEach((t=>{n.push(encodeURIComponent(e)+"[]="+encodeURIComponent(t))})):n.push(encodeURIComponent(e)+"="+encodeURIComponent(r)))}return console.log(n.length?e+n.join("&"):""),n.length?e+n.join("&"):""}return console.log(!1),!1},exports.merge=function(e,r){const n=Object.prototype.toString.call(e);if("Array"==n.slice(8,-1))return e.push.apply(e,r),t(e);if("Object"==n.slice(8,-1))return Object.assign(e,r)},exports.is=r,exports.unique=function(r){if(0==e(r)){let e=t(r);return console.log(e),e}return console.log(!1),!1},exports.first=function(t){if(0!=e(t))return console.log(!1),!1;if("[object Object]"===Object.prototype.toString.call(t))for(const e of t)return console.log(e),e;else console.log(t[0])},exports.last=function(t){if(0!=e(t))return console.log(!1),!1;if("[object Object]"===Object.prototype.toString.call(t))for(const e of t)console.log(e);else console.log(t[t.length-1])},exports.findByIndex=function(t,e,r){return(t||[]).findIndex((t=>t[e]===r))},exports.setObjData=function(t,e,r,n,o){try{return t.find((function(t){return t[e]==r}))[n]=o,!0}catch(t){return!1}},exports.selectObjData=function(t,e,r){try{return t.find((function(t){return t[e]==r}))}catch(t){return""}},exports.handleTree=function(t,e,r,n){const o={id:e||"id",parentId:r||"parentId",childrenList:n||"children"},c=new Map,i=new Map,s=[];let a=t.length;for(let e=0;e<a;e++){let r=t[e];const n=r[o.parentId];c.has(n)||c.set(n,[]),i.set(r[o.id],r),c.get(n).push(r)}for(let e=0;e<a;e++){let r=t[e];const n=r[o.parentId];i.has(n)||s.push(r)}const u=[...s];for(;u.length>0;){const t=u.pop(),e=c.get(t[o.id]);e&&(t[o.childrenList]=e,u.push(...e))}return s},exports.arrToTree=function(t,e={}){let{id:r="id",pKey:n="parentId",cKey:o="children",strict:c=!0,copy:i=!0}=e,s=[];s=i?JSON.parse(JSON.stringify(t)):t;return s.filter((t=>{const e=s.filter((e=>c?e[n]===t[r]:e[n]==t[r]));return e.length&&(t[o]=e),0===t[n]}))},exports.treeToArr=function(t,e={}){let r=[],{cKey:n="children",copy:o=!0}=e,c=[...t];for(;c.length;){let t=c.pop();if(t[n])if(c.push(...t[n]),o){let e={},o=Object.keys(t),c=o.length;for(let r=0;r<c;r++)o[r]!=n&&(e[o[r]]=t[o[r]]);r.push(e)}else r.push(t)}return r},exports.treeFor=function(t,r,n={}){let{cKey:o="children"}=n,c=[...t];for(;c.length;){let t=c.shift();e(t[o])?r&&r(t):c.push(...t[o])}},exports.treeStack=function(t,r,n={}){let{cKey:o="children"}=n,c=[...t];for(;c.length;){let t=c.shift();e(t[o])?r&&r(t):c.push(...t[o])}},exports.treeRecursion=function(t,e,r={}){},exports.treeFind=function(t,e={}){let r=[],{cKey:n="children",key:o="id",value:c,copy:i=!0}=e,s=[...t];for(;s.length;){let t=s.pop();if(t[n]&&s.push(...t[n]),t[o]==c)if(i){let e={},o=Object.keys(t),c=o.length;for(let r=0;r<c;r++)o[r]!=n&&(e[o[r]]=t[o[r]]);r.push(e)}else r.push(t)}return r},exports.base64Img=function(t,e){return r=function(t){for(var e=t.split(","),r=e[0].match(/:(.*?);/)[1],n=atob(e[1]),o=n.length,c=new Uint8Array(o);o--;)c[o]=n.charCodeAt(o);return new Blob([c],{type:r})}(t),n=e,new File([r],n);var r,n},exports.compareDate=function(t,e="up"){return function(r,n){return"up"==e?Date.parse(r[t])-Date.parse(n[t]):Date.parse(n[t])-Date.parse(r[t])}},exports.compare=function(t,e="up"){return function(r,n){return"up"==e?r[t]-n[t]:n[t]-r[t]}},exports.numberRepair=function(t="",e=2,r="0",n=!1){let o="",c=(""+t).length;if(c>e&&1==n)return c;{let n=e-c;if(n>0)for(let t=0;t<n;t++)o+=r;return(o+t).slice(-1*e)}},exports.isMobile=n,exports.setMeta=function(t){if(!e(t)){let e=[];document.head.childNodes.forEach((r=>{switch(r.tagName){case"META":e.push(r);break;case"TITLE":document.title=t.title||"模板测试"}}));const r=document.createElement("META");let o=1,c="yes";t.cZoom&&(n()?t.cZoom.mobile&&(o=t.cZoom.mobile):t.cZoom.pc&&(o=t.cZoom.pc),t.cZoom.isScale&&(c=t.cZoom.isScale));let i=`width=device-width,minimum-scale=${o},initial-scale=${o},user-scalable=${c}`;"no"==c&&(i+=`,maximum-scale=${o}`);const s=[{charset:"utf-8"},{name:"viewport",content:i}],a=document.createDocumentFragment();s.forEach((t=>{a.append(r.cloneNode()),Object.entries(t).forEach((t=>{a.lastChild.setAttribute(t[0],t[1])}))})),e.forEach((t=>{document.head.removeChild(t)})),document.head.prepend(a)}},exports.colorMix=function(t,e,r){r=Math.max(Math.min(Number(r),1),0);let n=parseInt(t.substring(1,3),16),o=parseInt(t.substring(3,5),16),c=parseInt(t.substring(5,7),16),i=parseInt(e.substring(1,3),16),s=parseInt(e.substring(3,5),16),a=parseInt(e.substring(5,7),16),u=Math.round(n*(1-r)+i*r),l=Math.round(o*(1-r)+s*r),p=Math.round(c*(1-r)+a*r);return u=("0"+(u||0).toString(16)).slice(-2),l=("0"+(l||0).toString(16)).slice(-2),p=("0"+(p||0).toString(16)).slice(-2),"#"+u+l+p},exports.sArrMove=function(t,e,r){t.splice(r,0,t.splice(e,1)[0])},exports.rArrMove=function(t,e,r){let n=[].concat(t);return n.splice(r,0,n.splice(e,1)[0]),n},exports.arrSet=function(t,e,r){t.splice(e,0,r)},exports.randomColor=function(){let t=o(100,255),e=o(100,255),r=o(100,255);return"rgba("+t+","+e+","+r+",1)"},exports.randomNumber=o,exports.isDateInRange=function(t,e,r){const n=new Date(t),o=new Date(e),c=new Date(r);return n>=o&&n<=c},exports.throttle1=function(t,e){let r,n=0;return function(...o){const c=Date.now(),i=c-n;clearTimeout(r),i>=e?(t(...o),n=c):r=setTimeout((()=>{t(...o),n=Date.now()}),e-i)}},exports.throttle=function(t,e=1e3,r=!0){let n;return(...o)=>{n&&clearInterval(n),r?(n||t(...o),n=setTimeout((function(){n=null}),e)):n=setTimeout((()=>{t(...o)}),e)}},exports.debounce=function(t,e){let r;return function(...n){clearTimeout(r),r=setTimeout((()=>{t(...n)}),e)}},exports.arrayGroup=function(t,e="type"){return t.reduce(((t,r)=>{var n;return Object.assign(Object.assign({},t),{[r[e]]:[...null!==(n=t[r[e]])&&void 0!==n?n:[],r]})}),{})},exports.numberFixed=function(t,e=1){const r=t.toString(),n=r.indexOf(".");if(-1===n)return t;const o=r.slice(0,n+1+e);return parseFloat(o)},exports.delObj=function(t,n=""){try{if(e(n)){let e=Object.keys(t);for(let r of e)delete t[r]}else if("Array"==r(n))for(const e of n)delete t[e];else delete t[n]}catch(t){}},exports.delObjEmptyKey=function(t){try{let n=Object.keys(t);for(let o of n)"Number"!=r(t[o])&&e(t[o])&&delete t[o]}catch(t){}},exports.isNum=c,exports.pxToRem=function(t,e=37.5){let r=t;if(c(t)||-1!=t.indexOf("px")){r=(parseFloat(t)/e).toFixed(2)+"rem"}return r},exports.inArr=function(t=[],e,r=!1){if(r)return t.indexOf(e);{let r=-1,n=t.length;for(let o=0;o<n;o++)t[o]==e&&(r=o);return r}},exports.fnRuntime=function(t,e=1){let r=0;for(let n=0;n<e;n++){const e=performance.now();t();r+=performance.now()-e}const n=r/e;console.log(`平均执行时间 ${e} 次数: ${n.toFixed(6)} ms`)},Number.prototype.repair=function(t=2){let e="";for(let r=1;r<t;r++)e+="0";return(e+this).slice(-1*t)};exports.auth=class{constructor(t){this.authList=[],this.authObj={},this.authList=t,new.target&&this.init()}init(){let t=this.authList.length;for(let e=0;e<t;e++){let t=1<<e;console.log(t,"num2");let r=this.authList[e];this.authObj[r]=t}console.log(this.authObj,"authObj")}add(t,e=[]){for(const r of e)t|=this.authObj[r];return t}del(t,e=[]){for(const r of e){let e=this.authObj[r];t&e&&(t^=e)}return t}andHave(t,e=[]){let r=!0;for(const n of e){if(!(t&this.authObj[n])){r=!1;break}}return r}orHave(t,e=[]){let r=!1;for(const n of e){if(t&this.authObj[n]){r=!0;break}}return r}};
|
|
1
|
+
function t(t){let e={};return t.forEach((function(t){e[JSON.stringify(t)]=t})),t=Object.keys(e).map((function(t){if("undefined"!=t)return JSON.parse(t)}))}function e(t){let e=!1;switch(Object.prototype.toString.call(t).slice(8,-1)){case"Undefined":case"Null":e=!0;break;case"String":e=0===t.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g,"").length;break;case"Boolean":e=!t;break;case"Array":e=0===t.length;break;case"Number":e=0===t||isNaN(t);break;case"Object":e=0===Object.keys(t).length}return e}function r(t){return Object.prototype.toString.call(t).slice(8,-1)}function n(){return!e(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))}function o(t,e){return Math.round(Math.random()*(e-t))+t}function c(t){let e=Number(t);return!isNaN(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.auth=void 0,exports.del_repeat=t,exports.formatDate=function(t,e="day",r="-"){let n=t.getFullYear(),o=(t.getMonth()+1).toString().padStart(2,"0"),c=t.getDate().toString().padStart(2,"0"),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0"),a={year:1,month:2,day:3,hour:4,minute:5},u="";for(let t=0;t<a[e];t++)0==t&&(u+=n),1==t&&(u+=o),2==t&&(u+=c),3==t&&(u+=i),4==t&&(u+=s),t!=a[e]-1&&(u+=r);return u},exports.time_change=function(t){return Date.parse(t)},exports.formatTime=function(t,e="YYYY-MM-DD hh:mm:ss",n="-"){var o;try{t=t.replaceAll("-","/")}catch(t){}let c=(t=new Date(t)).getFullYear(),i=(t.getMonth()+1).toString().padStart(2,"0"),s=t.getDate().toString().padStart(2,"0"),a=t.getHours().toString().padStart(2,"0"),u=t.getMinutes().toString().padStart(2,"0"),l=t.getSeconds().toString().padStart(2,"0"),p={0:"周日",1:"周一",2:"周二",3:"周三",4:"周四",5:"周五",6:"周六"}[t.getDay()],f=a>12?"下午":"上午",h=[];h=[{group:1,connect:"Object"==r(n)&&null!==(o=n.YYYY)&&void 0!==o?o:"",format:"YYYY",data:c},{group:1,connect:"",format:"yyyy",data:c},{group:1,connect:n,format:"MM",data:i},{group:1,connect:n,format:"DD",data:s},{group:1,connect:n,format:"dd",data:s},{group:2,connect:" ",format:"hh",data:a},{group:2,connect:" ",format:"HH",data:a},{group:2,connect:":",format:"mm",data:u},{group:2,connect:":",format:"ss",data:l},{group:3,connect:" ",format:"week",data:p},{group:4,connect:" ",format:"time_slot",data:f}];let d=0,g="";return h.forEach((function(t,r){if(-1!=e.indexOf(t.format)){let e="";0!=d&&(e=t.connect),g+=e+t.data,d++}})),g},exports.getDaysBetween=function(t,e,r=!1){var n=Date.parse(t),o=Date.parse(e),c=0;n>o&&(c=(n-o)/864e5);n<o&&(c=(o-n)/864e5,r&&(c=-c));return c},exports.is_empty=e,exports.repalce=function(t,e,r){return t.substring(0,e)+r+t.substring(e+1)},exports.param=function(t,r=!0){if(0==e(t)){let e=r?"?":"",n=[];for(let e in t){let r=t[e];["",void 0,null].includes(r)||(r.constructor===Array?r.forEach((t=>{n.push(encodeURIComponent(e)+"[]="+encodeURIComponent(t))})):n.push(encodeURIComponent(e)+"="+encodeURIComponent(r)))}return console.log(n.length?e+n.join("&"):""),n.length?e+n.join("&"):""}return console.log(!1),!1},exports.merge=function(e,r){const n=Object.prototype.toString.call(e);if("Array"==n.slice(8,-1))return e.push.apply(e,r),t(e);if("Object"==n.slice(8,-1))return Object.assign(e,r)},exports.is=r,exports.unique=function(r){if(0==e(r)){let e=t(r);return console.log(e),e}return console.log(!1),!1},exports.first=function(t){if(0!=e(t))return console.log(!1),!1;if("[object Object]"===Object.prototype.toString.call(t))for(const e of t)return console.log(e),e;else console.log(t[0])},exports.last=function(t){if(0!=e(t))return console.log(!1),!1;if("[object Object]"===Object.prototype.toString.call(t))for(const e of t)console.log(e);else console.log(t[t.length-1])},exports.findByIndex=function(t,e,r){return(t||[]).findIndex((t=>t[e]===r))},exports.setObjData=function(t,e,r,n,o){try{return t.find((function(t){return t[e]==r}))[n]=o,!0}catch(t){return!1}},exports.selectObjData=function(t,e,r){try{return t.find((function(t){return t[e]==r}))}catch(t){return""}},exports.handleTree=function(t,e,r,n){const o={id:e||"id",parentId:r||"parentId",childrenList:n||"children"},c=new Map,i=new Map,s=[];let a=t.length;for(let e=0;e<a;e++){let r=t[e];const n=r[o.parentId];c.has(n)||c.set(n,[]),i.set(r[o.id],r),c.get(n).push(r)}for(let e=0;e<a;e++){let r=t[e];const n=r[o.parentId];i.has(n)||s.push(r)}const u=[...s];for(;u.length>0;){const t=u.pop(),e=c.get(t[o.id]);e&&(t[o.childrenList]=e,u.push(...e))}return s},exports.arrToTree=function(t,e={}){let{id:r="id",pKey:n="parentId",cKey:o="children",strict:c=!0,copy:i=!0}=e,s=[];s=i?JSON.parse(JSON.stringify(t)):t;return s.filter((t=>{const e=s.filter((e=>c?e[n]===t[r]:e[n]==t[r]));return e.length&&(t[o]=e),0===t[n]}))},exports.treeToArr=function(t,e={}){let r=[],{cKey:n="children",copy:o=!0}=e,c=[...t];for(;c.length;){let t=c.pop();if(t[n])if(c.push(...t[n]),o){let e={},o=Object.keys(t),c=o.length;for(let r=0;r<c;r++)o[r]!=n&&(e[o[r]]=t[o[r]]);r.push(e)}else r.push(t)}return r},exports.treeFor=function(t,r,n={}){let{cKey:o="children"}=n,c=[...t];for(;c.length;){let t=c.shift();e(t[o])?r&&r(t):c.push(...t[o])}},exports.treeStack=function(t,r,n={}){let{cKey:o="children"}=n,c=[...t];for(;c.length;){let t=c.shift();e(t[o])?r&&r(t):c.push(...t[o])}},exports.treeRecursion=function(t,e,r={}){},exports.treeFind=function(t,e={}){let r=[],{cKey:n="children",key:o="id",value:c,copy:i=!0}=e,s=[...t];for(;s.length;){let t=s.pop();if(t[n]&&s.push(...t[n]),t[o]==c)if(i){let e={},o=Object.keys(t),c=o.length;for(let r=0;r<c;r++)o[r]!=n&&(e[o[r]]=t[o[r]]);r.push(e)}else r.push(t)}return r},exports.base64Img=function(t,e){return r=function(t){for(var e=t.split(","),r=e[0].match(/:(.*?);/)[1],n=atob(e[1]),o=n.length,c=new Uint8Array(o);o--;)c[o]=n.charCodeAt(o);return new Blob([c],{type:r})}(t),n=e,new File([r],n);var r,n},exports.compareDate=function(t,e="up"){return function(r,n){return"up"==e?Date.parse(r[t])-Date.parse(n[t]):Date.parse(n[t])-Date.parse(r[t])}},exports.compare=function(t,e="up"){return function(r,n){return"up"==e?r[t]-n[t]:n[t]-r[t]}},exports.numberRepair=function(t="",e=2,r="0",n=!1){let o="",c=(""+t).length;if(c>e&&1==n)return c;{let n=e-c;if(n>0)for(let t=0;t<n;t++)o+=r;return(o+t).slice(-1*e)}},exports.isMobile=n,exports.setMeta=function(t){if(!e(t)){let e=[];document.head.childNodes.forEach((r=>{switch(r.tagName){case"META":e.push(r);break;case"TITLE":document.title=t.title||"模板测试"}}));const r=document.createElement("META");let o=1,c="yes";t.cZoom&&(n()?t.cZoom.mobile&&(o=t.cZoom.mobile):t.cZoom.pc&&(o=t.cZoom.pc),t.cZoom.isScale&&(c=t.cZoom.isScale));let i=`width=device-width,minimum-scale=${o},initial-scale=${o},user-scalable=${c}`;"no"==c&&(i+=`,maximum-scale=${o}`);const s=[{charset:"utf-8"},{name:"viewport",content:i}],a=document.createDocumentFragment();s.forEach((t=>{a.append(r.cloneNode()),Object.entries(t).forEach((t=>{a.lastChild.setAttribute(t[0],t[1])}))})),e.forEach((t=>{document.head.removeChild(t)})),document.head.prepend(a)}},exports.colorMix=function(t,e,r){r=Math.max(Math.min(Number(r),1),0);let n=parseInt(t.substring(1,3),16),o=parseInt(t.substring(3,5),16),c=parseInt(t.substring(5,7),16),i=parseInt(e.substring(1,3),16),s=parseInt(e.substring(3,5),16),a=parseInt(e.substring(5,7),16),u=Math.round(n*(1-r)+i*r),l=Math.round(o*(1-r)+s*r),p=Math.round(c*(1-r)+a*r);return u=("0"+(u||0).toString(16)).slice(-2),l=("0"+(l||0).toString(16)).slice(-2),p=("0"+(p||0).toString(16)).slice(-2),"#"+u+l+p},exports.sArrMove=function(t,e,r){t.splice(r,0,t.splice(e,1)[0])},exports.rArrMove=function(t,e,r){let n=[].concat(t);return n.splice(r,0,n.splice(e,1)[0]),n},exports.arrSet=function(t,e,r){t.splice(e,0,r)},exports.randomColor=function(){let t=o(100,255),e=o(100,255),r=o(100,255);return"rgba("+t+","+e+","+r+",1)"},exports.randomNumber=o,exports.isDateInRange=function(t,e,r){const n=new Date(t),o=new Date(e),c=new Date(r);return n>=o&&n<=c},exports.throttle1=function(t,e){let r,n=0;return function(...o){const c=Date.now(),i=c-n;clearTimeout(r),i>=e?(t(...o),n=c):r=setTimeout((()=>{t(...o),n=Date.now()}),e-i)}},exports.throttle=function(t,e=1e3,r=!0){let n;return(...o)=>{n&&clearInterval(n),r?(n||t(...o),n=setTimeout((function(){n=null}),e)):n=setTimeout((()=>{t(...o)}),e)}},exports.debounce=function(t,e){let r;return function(...n){clearTimeout(r),r=setTimeout((()=>{t(...n)}),e)}},exports.arrayGroup=function(t,e="type"){return t.reduce(((t,r)=>{var n;return Object.assign(Object.assign({},t),{[r[e]]:[...null!==(n=t[r[e]])&&void 0!==n?n:[],r]})}),{})},exports.numberFixed=function(t,e=1){const r=t.toString(),n=r.indexOf(".");if(-1===n)return t;const o=r.slice(0,n+1+e);return parseFloat(o)},exports.delObj=function(t,n=""){try{if(e(n)){let e=Object.keys(t);for(let r of e)delete t[r]}else if("Array"==r(n))for(const e of n)delete t[e];else delete t[n]}catch(t){}},exports.delObjEmptyKey=function(t){try{let n=Object.keys(t);for(let o of n)"Number"!=r(t[o])&&e(t[o])&&delete t[o]}catch(t){}},exports.isNum=c,exports.pxToRem=function(t,e=37.5){let r=t;if(c(t)||-1!=t.indexOf("px")){r=(parseFloat(t)/e).toFixed(2)+"rem"}return r},exports.inArr=function(t=[],e,r=!1){if(r)return t.indexOf(e);{let r=-1,n=t.length;for(let o=0;o<n;o++)t[o]==e&&(r=o);return r}},exports.fnRuntime=function(t,e=1){let r=0;for(let n=0;n<e;n++){const e=performance.now();t();r+=performance.now()-e}const n=r/e;console.log(`平均执行时间 ${e} 次数: ${n.toFixed(6)} ms`)},Number.prototype.repair=function(t=2){let e="";for(let r=1;r<t;r++)e+="0";return(e+this).slice(-1*t)};exports.auth=class{constructor(t){this.authList=[],this.authObj={},this.authList=t,new.target&&this.init()}init(){let t=this.authList.length;for(let e=0;e<t;e++){let t=1<<e,r=this.authList[e];this.authObj[r]=t}}add(t,e=[]){for(const r of e)t|=this.authObj[r];return t}del(t,e=[]){for(const r of e){t&=~this.authObj[r]}return t}andHave(t,e=[]){let r=!0;for(const n of e){if(!(t&this.authObj[n])){r=!1;break}}return r}orHave(t,e=[]){let r=!1;for(const n of e){if(t&this.authObj[n]){r=!0;break}}return r}havaTxt(t){let e=[];for(const r of this.authList){t&this.authObj[r]&&e.push(r)}return e}};
|