devix 0.0.16 → 0.0.17

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/index.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";const t={string:t=>"string"==typeof t,number:t=>"number"==typeof t,boolean:t=>"boolean"==typeof t,null:t=>null===t,undefined:t=>void 0===t,symbol:t=>"symbol"==typeof t,bigint:t=>"bigint"==typeof t,object:t=>null!==t&&"object"==typeof t,array:t=>Array.isArray(t),function:t=>"function"==typeof t,set:t=>t instanceof Set,map:t=>t instanceof Map,date:t=>t instanceof Date,regexp:t=>t instanceof RegExp},e=(e,n)=>t[e]?.(n)||!1;var n;!function(t){t[t.Local=0]="Local",t[t.Session=1]="Session"}(n||(n={}));class o{constructor(t){this.storage=t===n.Local?localStorage:sessionStorage}getCache(t){const e=this.storage.getItem(t);return e?JSON.parse(e):null}setCache(t,e){this.storage.setItem(t,JSON.stringify(e))}updateCache(t,n,o){const r=this.getCache(t);e("object",r)&&(r[n]=o,this.setCache(t,r))}deleteCache(t){this.storage.removeItem(t)}clearCache(){this.storage.clear()}}const r=new o(n.Local),s=new o(n.Session);
2
2
  //! Function Deep Copy
3
- const i=t=>e("object",t)||e("function",t);var c;function a(t,e,n){[t[e],t[n]]=[t[n],t[e]]}function u(t,e,n){return n===c.ASC?t>e:t<e}!function(t){t.ASC="ASC",t.DESC="DESC"}(c||(c={}));const l=new Map([["yyyy","year"],["MM","month"],["dd","day"],["HH","hours"],["mm","minutes"],["ss","seconds"],["W","week"]]),f=new Map([[1,"一"],[2,"二"],[3,"三"],[4,"四"],[5,"五"],[6,"六"],[0,"日"]]);function p(t){return t.toString().padStart(2,"0")}exports.bubblingSort=function(t,e=c.ASC,n){const o=t.length;if(o<2)return t;for(let r=0;r<o-1;r++)for(let s=0;s<o-1-r;s++){u(n?t[s][n]:t[s],n?t[s+1][n]:t[s+1],e)&&a(t,s,s+1)}return t},exports.compose=function(...t){const e=t.length;if(!(e<=0)){for(let n=0;n<e;n++){if("function"!=typeof t[n])throw new Error(`argument with index ${n} is not a function`)}return function(...n){let o=0,r=t[o].apply(this,n);for(;++o<e;)r=t[o].call(this,r);return r}}},exports.currying=function(t){return function e(...n){return n.length>=t.length?t.apply(this,n):function(...t){return e.apply(this,n.concat(t))}}},exports.debounce=function(t,e=0,n=!1){let o=null,r=!1;function s(...s){return new Promise(((i,c)=>{if(null!==o&&clearTimeout(o),!n||r)o=setTimeout((()=>{try{const e=t.apply(this,s);i(e)}catch(t){c(t)}finally{o=null,r=!1}}),e);else{try{const e=t.apply(this,s);i(e)}catch(t){c(t)}r=!0}}))}return s.cancel=function(){null!==o&&clearTimeout(o),o=null,r=!1},s},exports.deepClone=function t(n,o=new WeakMap){if(o.get(n))return o.get(n);const r=function(t,n,o){if(e("symbol",t))return Symbol(t.description);if(!i(t))return t;if(e("set",t)){const e=new Set;return t.forEach((t=>e.add(n(t,o)))),e}if(e("map",t)){const e=new Map;return t.forEach(((t,r)=>e.set(r,n(t,o)))),e}}(n,t,o);if(r)return r;const s=e("array",n),c=s?[]:{};return o.set(n,c),s?n.forEach(((e,n)=>{c[n]=t(e,o)})):(Object.keys(n).forEach((e=>{c[e]=t(n[e],o)})),Object.getOwnPropertySymbols(n).forEach((e=>{c[Symbol(e.description)]=t(n[e],o)}))),c},exports.formatTimer=(t,n="yyyy-MM-dd HH:mm:ss")=>{if(!t)return(new Date).toISOString();const o=function(t){const e=0===t.getDay()?7:t.getDay();return{year:t.getFullYear().toString(),month:p(t.getMonth()+1),day:p(t.getDate()),hours:p(t.getHours()),minutes:p(t.getMinutes()),seconds:p(t.getSeconds()),week:(n=e,f.get(n)||""),weekNum:e.toString()};var n}(new Date(t));if(e("string",n)&&!n.trim())return o;return Array.from(l).reduce(((t,[e,n])=>t.replace(new RegExp(e,"g"),o[n])),n)},exports.insertStr=function(t,e,n){return t.slice(0,e)+n+t.slice(e)},exports.isType=e,exports.localCache=r,exports.sessionCache=s,exports.setTimer=function(t,e,n){let o=null;const r=()=>{t(),o=setTimeout(r,e)};return n&&t(),setTimeout(r,e),{cancel:()=>{null!==o&&clearTimeout(o)}}},exports.shallowClone=
3
+ const i=t=>e("object",t)||e("function",t);var c;function a(t,e,n){[t[e],t[n]]=[t[n],t[e]]}function u(t,e,n){return n===c.ASC?t>e:t<e}!function(t){t.ASC="ASC",t.DESC="DESC"}(c||(c={}));const l=new Map([["yyyy","year"],["MM","month"],["dd","day"],["HH","hours"],["mm","minutes"],["ss","seconds"],["W","week"]]),f=new Map([[1,"一"],[2,"二"],[3,"三"],[4,"四"],[5,"五"],[6,"六"],[0,"日"]]);function p(t){return t.toString().padStart(2,"0")}exports.bubblingSort=function(t,e=c.ASC,n){const o=t.length;if(o<2)return t;for(let r=0;r<o-1;r++)for(let s=0;s<o-1-r;s++){u(n?t[s][n]:t[s],n?t[s+1][n]:t[s+1],e)&&a(t,s,s+1)}return t},exports.compose=function(...t){const e=t.length;if(!(e<=0)){for(let n=0;n<e;n++){if("function"!=typeof t[n])throw new Error(`argument with index ${n} is not a function`)}return function(...n){let o=0,r=t[o].apply(this,n);for(;++o<e;)r=t[o].call(this,r);return r}}},exports.currying=function(t){return function e(...n){return n.length>=t.length?t.apply(this,n):function(...t){return e.apply(this,n.concat(t))}}},exports.debounce=function(t,e=0,n=!1){let o=null,r=!1;function s(...s){return new Promise(((i,c)=>{if(null!==o&&clearTimeout(o),!n||r)o=setTimeout((()=>{try{const e=t.apply(this,s);i(e)}catch(t){c(t)}finally{o=null,r=!1}}),e);else{try{const e=t.apply(this,s);i(e)}catch(t){c(t)}r=!0}}))}return s.cancel=function(){null!==o&&clearTimeout(o),o=null,r=!1},s},exports.deepClone=function t(n,o=new WeakMap){if(o.get(n))return o.get(n);const r=function(t,n,o){if(e("symbol",t))return Symbol(t.description);if(!i(t))return t;if(e("set",t)){const e=new Set;return t.forEach((t=>e.add(n(t,o)))),e}if(e("map",t)){const e=new Map;return t.forEach(((t,r)=>e.set(r,n(t,o)))),e}}(n,t,o);if(r)return r;const s=e("array",n),c=s?[]:{};return o.set(n,c),s?n.forEach(((e,n)=>{c[n]=t(e,o)})):(Object.keys(n).forEach((e=>{c[e]=t(n[e],o)})),Object.getOwnPropertySymbols(n).forEach((e=>{c[Symbol(e.description)]=t(n[e],o)}))),c},exports.formatTimer=(t,n="yyyy-MM-dd HH:mm:ss")=>{if(!t)return(new Date).toISOString();const o=function(t){const e=0===t.getDay()?7:t.getDay();return{year:t.getFullYear().toString(),month:p(t.getMonth()+1),day:p(t.getDate()),hours:p(t.getHours()),minutes:p(t.getMinutes()),seconds:p(t.getSeconds()),week:(n=e,f.get(n)||""),weekNum:e.toString()};var n}(new Date(t));if(e("string",n)&&!n.trim())return o;return Array.from(l).reduce(((t,[e,n])=>t.replace(new RegExp(e,"g"),o[n])),n)},exports.insertStr=function(t,e,n){return t.slice(0,e)+n+t.slice(e)},exports.isType=e,exports.localCache=r,exports.sessionCache=s,exports.setTimer=function(t,e=0,n=!1){let o=null;const r=()=>{t(),o=setTimeout(r,e)};return n&&t(),setTimeout(r,e),{cancel:()=>{null!==o&&clearTimeout(o)}}},exports.shallowClone=
4
4
  //! Function Shallow Copy
5
5
  function(t){return e("array",t)?t.slice():e("object",t)?{...t}:t},exports.stringCase=function(t,e="",n=""){const o=t.split(e);for(let t=0;t<o.length;t++)o[t]=o[t].slice(0,1).toUpperCase()+o[t].slice(1).toLowerCase();return o.join(n)},exports.throttle=function(t,e,n={}){const{leading:o=!0,trailing:r=!1}=n;let s=0,i=null;function c(...n){return new Promise(((c,a)=>{try{const a=Date.now();let u;o||0!==s||(s=a);const l=e-(a-s);if(l<=0)return i&&clearTimeout(i),u=t.apply(this,n),c(u),s=a,void(i=null);r&&!i&&(i=setTimeout((()=>{u=t.apply(this,n),c(u),s=Date.now(),i=null}),l))}catch(t){a(t)}}))}return c.cancel=function(){i&&clearTimeout(i),s=0,i=null},c};
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ declare function currying(fn: Function): (this: any, ...args: any[]) => any;
2
2
  declare function compose(...fns: Function[]): ((this: any, ...args: any[]) => any) | undefined;
3
3
  declare function insertStr(soure: string, start: number, newStr: string): string;
4
4
  declare function stringCase(soure: string, separator?: string, separate?: string): string;
5
- declare function setTimer(execute: (...args: any[]) => any, delay: number, immediate: boolean): {
5
+ declare function setTimer(execute: (...args: any[]) => any, delay?: number, immediate?: boolean): {
6
6
  cancel: () => void;
7
7
  };
8
8
 
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- function t(t){return function e(...n){return n.length>=t.length?t.apply(this,n):function(...t){return e.apply(this,n.concat(t))}}}function e(...t){const e=t.length;if(!(e<=0)){for(let n=0;n<e;n++){if("function"!=typeof t[n])throw new Error(`argument with index ${n} is not a function`)}return function(...n){let o=0,r=t[o].apply(this,n);for(;++o<e;)r=t[o].call(this,r);return r}}}function n(t,e,n){return t.slice(0,e)+n+t.slice(e)}function o(t,e="",n=""){const o=t.split(e);for(let t=0;t<o.length;t++)o[t]=o[t].slice(0,1).toUpperCase()+o[t].slice(1).toLowerCase();return o.join(n)}function r(t,e,n){let o=null;const r=()=>{t(),o=setTimeout(r,e)};return n&&t(),setTimeout(r,e),{cancel:()=>{null!==o&&clearTimeout(o)}}}const c={string:t=>"string"==typeof t,number:t=>"number"==typeof t,boolean:t=>"boolean"==typeof t,null:t=>null===t,undefined:t=>void 0===t,symbol:t=>"symbol"==typeof t,bigint:t=>"bigint"==typeof t,object:t=>null!==t&&"object"==typeof t,array:t=>Array.isArray(t),function:t=>"function"==typeof t,set:t=>t instanceof Set,map:t=>t instanceof Map,date:t=>t instanceof Date,regexp:t=>t instanceof RegExp},i=(t,e)=>c[t]?.(e)||!1;var s;!function(t){t[t.Local=0]="Local",t[t.Session=1]="Session"}(s||(s={}));class a{constructor(t){this.storage=t===s.Local?localStorage:sessionStorage}getCache(t){const e=this.storage.getItem(t);return e?JSON.parse(e):null}setCache(t,e){this.storage.setItem(t,JSON.stringify(e))}updateCache(t,e,n){const o=this.getCache(t);i("object",o)&&(o[e]=n,this.setCache(t,o))}deleteCache(t){this.storage.removeItem(t)}clearCache(){this.storage.clear()}}const u=new a(s.Local),l=new a(s.Session);function f(t,e=0,n=!1){let o=null,r=!1;function c(...c){return new Promise(((i,s)=>{if(null!==o&&clearTimeout(o),!n||r)o=setTimeout((()=>{try{const e=t.apply(this,c);i(e)}catch(t){s(t)}finally{o=null,r=!1}}),e);else{try{const e=t.apply(this,c);i(e)}catch(t){s(t)}r=!0}}))}return c.cancel=function(){null!==o&&clearTimeout(o),o=null,r=!1},c}function y(t,e,n={}){const{leading:o=!0,trailing:r=!1}=n;let c=0,i=null;function s(...n){return new Promise(((s,a)=>{try{const a=Date.now();let u;o||0!==c||(c=a);const l=e-(a-c);if(l<=0)return i&&clearTimeout(i),u=t.apply(this,n),s(u),c=a,void(i=null);r&&!i&&(i=setTimeout((()=>{u=t.apply(this,n),s(u),c=Date.now(),i=null}),l))}catch(t){a(t)}}))}return s.cancel=function(){i&&clearTimeout(i),c=0,i=null},s}
1
+ function t(t){return function e(...n){return n.length>=t.length?t.apply(this,n):function(...t){return e.apply(this,n.concat(t))}}}function e(...t){const e=t.length;if(!(e<=0)){for(let n=0;n<e;n++){if("function"!=typeof t[n])throw new Error(`argument with index ${n} is not a function`)}return function(...n){let o=0,r=t[o].apply(this,n);for(;++o<e;)r=t[o].call(this,r);return r}}}function n(t,e,n){return t.slice(0,e)+n+t.slice(e)}function o(t,e="",n=""){const o=t.split(e);for(let t=0;t<o.length;t++)o[t]=o[t].slice(0,1).toUpperCase()+o[t].slice(1).toLowerCase();return o.join(n)}function r(t,e=0,n=!1){let o=null;const r=()=>{t(),o=setTimeout(r,e)};return n&&t(),setTimeout(r,e),{cancel:()=>{null!==o&&clearTimeout(o)}}}const c={string:t=>"string"==typeof t,number:t=>"number"==typeof t,boolean:t=>"boolean"==typeof t,null:t=>null===t,undefined:t=>void 0===t,symbol:t=>"symbol"==typeof t,bigint:t=>"bigint"==typeof t,object:t=>null!==t&&"object"==typeof t,array:t=>Array.isArray(t),function:t=>"function"==typeof t,set:t=>t instanceof Set,map:t=>t instanceof Map,date:t=>t instanceof Date,regexp:t=>t instanceof RegExp},i=(t,e)=>c[t]?.(e)||!1;var s;!function(t){t[t.Local=0]="Local",t[t.Session=1]="Session"}(s||(s={}));class a{constructor(t){this.storage=t===s.Local?localStorage:sessionStorage}getCache(t){const e=this.storage.getItem(t);return e?JSON.parse(e):null}setCache(t,e){this.storage.setItem(t,JSON.stringify(e))}updateCache(t,e,n){const o=this.getCache(t);i("object",o)&&(o[e]=n,this.setCache(t,o))}deleteCache(t){this.storage.removeItem(t)}clearCache(){this.storage.clear()}}const u=new a(s.Local),l=new a(s.Session);function f(t,e=0,n=!1){let o=null,r=!1;function c(...c){return new Promise(((i,s)=>{if(null!==o&&clearTimeout(o),!n||r)o=setTimeout((()=>{try{const e=t.apply(this,c);i(e)}catch(t){s(t)}finally{o=null,r=!1}}),e);else{try{const e=t.apply(this,c);i(e)}catch(t){s(t)}r=!0}}))}return c.cancel=function(){null!==o&&clearTimeout(o),o=null,r=!1},c}function y(t,e,n={}){const{leading:o=!0,trailing:r=!1}=n;let c=0,i=null;function s(...n){return new Promise(((s,a)=>{try{const a=Date.now();let u;o||0!==c||(c=a);const l=e-(a-c);if(l<=0)return i&&clearTimeout(i),u=t.apply(this,n),s(u),c=a,void(i=null);r&&!i&&(i=setTimeout((()=>{u=t.apply(this,n),s(u),c=Date.now(),i=null}),l))}catch(t){a(t)}}))}return s.cancel=function(){i&&clearTimeout(i),c=0,i=null},s}
2
2
  //! Function Shallow Copy
3
3
  function g(t){return i("array",t)?t.slice():i("object",t)?{...t}:t}
4
4
  //! Function Deep Copy
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Evenex={})}(this,(function(t){"use strict";const e={string:t=>"string"==typeof t,number:t=>"number"==typeof t,boolean:t=>"boolean"==typeof t,null:t=>null===t,undefined:t=>void 0===t,symbol:t=>"symbol"==typeof t,bigint:t=>"bigint"==typeof t,object:t=>null!==t&&"object"==typeof t,array:t=>Array.isArray(t),function:t=>"function"==typeof t,set:t=>t instanceof Set,map:t=>t instanceof Map,date:t=>t instanceof Date,regexp:t=>t instanceof RegExp},n=(t,n)=>e[t]?.(n)||!1;var o;!function(t){t[t.Local=0]="Local",t[t.Session=1]="Session"}(o||(o={}));class r{constructor(t){this.storage=t===o.Local?localStorage:sessionStorage}getCache(t){const e=this.storage.getItem(t);return e?JSON.parse(e):null}setCache(t,e){this.storage.setItem(t,JSON.stringify(e))}updateCache(t,e,o){const r=this.getCache(t);n("object",r)&&(r[e]=o,this.setCache(t,r))}deleteCache(t){this.storage.removeItem(t)}clearCache(){this.storage.clear()}}const i=new r(o.Local),s=new r(o.Session);
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Devix={})}(this,(function(t){"use strict";const e={string:t=>"string"==typeof t,number:t=>"number"==typeof t,boolean:t=>"boolean"==typeof t,null:t=>null===t,undefined:t=>void 0===t,symbol:t=>"symbol"==typeof t,bigint:t=>"bigint"==typeof t,object:t=>null!==t&&"object"==typeof t,array:t=>Array.isArray(t),function:t=>"function"==typeof t,set:t=>t instanceof Set,map:t=>t instanceof Map,date:t=>t instanceof Date,regexp:t=>t instanceof RegExp},n=(t,n)=>e[t]?.(n)||!1;var o;!function(t){t[t.Local=0]="Local",t[t.Session=1]="Session"}(o||(o={}));class r{constructor(t){this.storage=t===o.Local?localStorage:sessionStorage}getCache(t){const e=this.storage.getItem(t);return e?JSON.parse(e):null}setCache(t,e){this.storage.setItem(t,JSON.stringify(e))}updateCache(t,e,o){const r=this.getCache(t);n("object",r)&&(r[e]=o,this.setCache(t,r))}deleteCache(t){this.storage.removeItem(t)}clearCache(){this.storage.clear()}}const i=new r(o.Local),s=new r(o.Session);
2
2
  //! Function Deep Copy
3
- const c=t=>n("object",t)||n("function",t);var a;function u(t,e,n){[t[e],t[n]]=[t[n],t[e]]}function l(t,e,n){return n===a.ASC?t>e:t<e}!function(t){t.ASC="ASC",t.DESC="DESC"}(a||(a={}));const f=new Map([["yyyy","year"],["MM","month"],["dd","day"],["HH","hours"],["mm","minutes"],["ss","seconds"],["W","week"]]),y=new Map([[1,"一"],[2,"二"],[3,"三"],[4,"四"],[5,"五"],[6,"六"],[0,"日"]]);function p(t){return t.toString().padStart(2,"0")}t.bubblingSort=function(t,e=a.ASC,n){const o=t.length;if(o<2)return t;for(let r=0;r<o-1;r++)for(let i=0;i<o-1-r;i++){l(n?t[i][n]:t[i],n?t[i+1][n]:t[i+1],e)&&u(t,i,i+1)}return t},t.compose=function(...t){const e=t.length;if(!(e<=0)){for(let n=0;n<e;n++){if("function"!=typeof t[n])throw new Error(`argument with index ${n} is not a function`)}return function(...n){let o=0,r=t[o].apply(this,n);for(;++o<e;)r=t[o].call(this,r);return r}}},t.currying=function(t){return function e(...n){return n.length>=t.length?t.apply(this,n):function(...t){return e.apply(this,n.concat(t))}}},t.debounce=function(t,e=0,n=!1){let o=null,r=!1;function i(...i){return new Promise(((s,c)=>{if(null!==o&&clearTimeout(o),!n||r)o=setTimeout((()=>{try{const e=t.apply(this,i);s(e)}catch(t){c(t)}finally{o=null,r=!1}}),e);else{try{const e=t.apply(this,i);s(e)}catch(t){c(t)}r=!0}}))}return i.cancel=function(){null!==o&&clearTimeout(o),o=null,r=!1},i},t.deepClone=function t(e,o=new WeakMap){if(o.get(e))return o.get(e);const r=function(t,e,o){if(n("symbol",t))return Symbol(t.description);if(!c(t))return t;if(n("set",t)){const n=new Set;return t.forEach((t=>n.add(e(t,o)))),n}if(n("map",t)){const n=new Map;return t.forEach(((t,r)=>n.set(r,e(t,o)))),n}}(e,t,o);if(r)return r;const i=n("array",e),s=i?[]:{};return o.set(e,s),i?e.forEach(((e,n)=>{s[n]=t(e,o)})):(Object.keys(e).forEach((n=>{s[n]=t(e[n],o)})),Object.getOwnPropertySymbols(e).forEach((n=>{s[Symbol(n.description)]=t(e[n],o)}))),s},t.formatTimer=(t,e="yyyy-MM-dd HH:mm:ss")=>{if(!t)return(new Date).toISOString();const o=function(t){const e=0===t.getDay()?7:t.getDay();return{year:t.getFullYear().toString(),month:p(t.getMonth()+1),day:p(t.getDate()),hours:p(t.getHours()),minutes:p(t.getMinutes()),seconds:p(t.getSeconds()),week:(n=e,y.get(n)||""),weekNum:e.toString()};var n}(new Date(t));if(n("string",e)&&!e.trim())return o;return Array.from(f).reduce(((t,[e,n])=>t.replace(new RegExp(e,"g"),o[n])),e)},t.insertStr=function(t,e,n){return t.slice(0,e)+n+t.slice(e)},t.isType=n,t.localCache=i,t.sessionCache=s,t.setTimer=function(t,e,n){let o=null;const r=()=>{t(),o=setTimeout(r,e)};return n&&t(),setTimeout(r,e),{cancel:()=>{null!==o&&clearTimeout(o)}}},t.shallowClone=
3
+ const c=t=>n("object",t)||n("function",t);var a;function u(t,e,n){[t[e],t[n]]=[t[n],t[e]]}function l(t,e,n){return n===a.ASC?t>e:t<e}!function(t){t.ASC="ASC",t.DESC="DESC"}(a||(a={}));const f=new Map([["yyyy","year"],["MM","month"],["dd","day"],["HH","hours"],["mm","minutes"],["ss","seconds"],["W","week"]]),y=new Map([[1,"一"],[2,"二"],[3,"三"],[4,"四"],[5,"五"],[6,"六"],[0,"日"]]);function p(t){return t.toString().padStart(2,"0")}t.bubblingSort=function(t,e=a.ASC,n){const o=t.length;if(o<2)return t;for(let r=0;r<o-1;r++)for(let i=0;i<o-1-r;i++){l(n?t[i][n]:t[i],n?t[i+1][n]:t[i+1],e)&&u(t,i,i+1)}return t},t.compose=function(...t){const e=t.length;if(!(e<=0)){for(let n=0;n<e;n++){if("function"!=typeof t[n])throw new Error(`argument with index ${n} is not a function`)}return function(...n){let o=0,r=t[o].apply(this,n);for(;++o<e;)r=t[o].call(this,r);return r}}},t.currying=function(t){return function e(...n){return n.length>=t.length?t.apply(this,n):function(...t){return e.apply(this,n.concat(t))}}},t.debounce=function(t,e=0,n=!1){let o=null,r=!1;function i(...i){return new Promise(((s,c)=>{if(null!==o&&clearTimeout(o),!n||r)o=setTimeout((()=>{try{const e=t.apply(this,i);s(e)}catch(t){c(t)}finally{o=null,r=!1}}),e);else{try{const e=t.apply(this,i);s(e)}catch(t){c(t)}r=!0}}))}return i.cancel=function(){null!==o&&clearTimeout(o),o=null,r=!1},i},t.deepClone=function t(e,o=new WeakMap){if(o.get(e))return o.get(e);const r=function(t,e,o){if(n("symbol",t))return Symbol(t.description);if(!c(t))return t;if(n("set",t)){const n=new Set;return t.forEach((t=>n.add(e(t,o)))),n}if(n("map",t)){const n=new Map;return t.forEach(((t,r)=>n.set(r,e(t,o)))),n}}(e,t,o);if(r)return r;const i=n("array",e),s=i?[]:{};return o.set(e,s),i?e.forEach(((e,n)=>{s[n]=t(e,o)})):(Object.keys(e).forEach((n=>{s[n]=t(e[n],o)})),Object.getOwnPropertySymbols(e).forEach((n=>{s[Symbol(n.description)]=t(e[n],o)}))),s},t.formatTimer=(t,e="yyyy-MM-dd HH:mm:ss")=>{if(!t)return(new Date).toISOString();const o=function(t){const e=0===t.getDay()?7:t.getDay();return{year:t.getFullYear().toString(),month:p(t.getMonth()+1),day:p(t.getDate()),hours:p(t.getHours()),minutes:p(t.getMinutes()),seconds:p(t.getSeconds()),week:(n=e,y.get(n)||""),weekNum:e.toString()};var n}(new Date(t));if(n("string",e)&&!e.trim())return o;return Array.from(f).reduce(((t,[e,n])=>t.replace(new RegExp(e,"g"),o[n])),e)},t.insertStr=function(t,e,n){return t.slice(0,e)+n+t.slice(e)},t.isType=n,t.localCache=i,t.sessionCache=s,t.setTimer=function(t,e=0,n=!1){let o=null;const r=()=>{t(),o=setTimeout(r,e)};return n&&t(),setTimeout(r,e),{cancel:()=>{null!==o&&clearTimeout(o)}}},t.shallowClone=
4
4
  //! Function Shallow Copy
5
5
  function(t){return n("array",t)?t.slice():n("object",t)?{...t}:t},t.stringCase=function(t,e="",n=""){const o=t.split(e);for(let t=0;t<o.length;t++)o[t]=o[t].slice(0,1).toUpperCase()+o[t].slice(1).toLowerCase();return o.join(n)},t.throttle=function(t,e,n={}){const{leading:o=!0,trailing:r=!1}=n;let i=0,s=null;function c(...n){return new Promise(((c,a)=>{try{const a=Date.now();let u;o||0!==i||(i=a);const l=e-(a-i);if(l<=0)return s&&clearTimeout(s),u=t.apply(this,n),c(u),i=a,void(s=null);r&&!s&&(s=setTimeout((()=>{u=t.apply(this,n),c(u),i=Date.now(),s=null}),l))}catch(t){a(t)}}))}return c.cancel=function(){s&&clearTimeout(s),i=0,s=null},c}}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "devix",
3
3
  "type": "module",
4
- "version": "0.0.16",
4
+ "version": "0.0.17",
5
5
  "description": "Devix is a comprehensive, powerful, and compact JavaScript utility library.",
6
6
  "author": "king-3 <w2196592083@gmail.com>",
7
7
  "license": "MIT",