@wxhccc/es-util 1.5.0 → 1.5.1

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.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wxhccc/es-util v1.5.0
2
+ * @wxhccc/es-util v1.5.1
3
3
  * (c) 2021 wxhccc
4
4
  * @license MIT
5
5
  */
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wxhccc/es-util v1.5.0
2
+ * @wxhccc/es-util v1.5.1
3
3
  * (c) 2021 wxhccc
4
4
  * @license MIT
5
5
  */
package/dist/index.min.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @wxhccc/es-util v1.5.0
2
+ * @wxhccc/es-util v1.5.1
3
3
  * (c) 2021 wxhccc
4
4
  * @license MIT
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Smartfetch={})}(this,(function(e){"use strict";const{hasOwnProperty:t}=Object.prototype;function n(e,t=[]){return{[e]:t}}const r=/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;const{hasOwnProperty:i,toString:c}=Object.prototype,o=e=>{const t=c.call(e).match(/^\[object (.*)\]$/);return t?t[1]:""};async function s(e){try{return[null,await e]}catch(e){return[e,void 0]}}const a={};const l=Object.defineProperty((function(e,t){const n=function(e){return e?e._isVue||e.$&&e.$.vnode?"vue":"setState"in e?"react":"unknown":"unknown"}(this),r="unknown"!==n,c=r?this:a,l="react"===n?"state":"",u=l?c[l]:c,{wrap:f,lock:p,syncRefHandle:y,manualUnlock:b}="boolean"==typeof t?{wrap:t}:{...t};let d,h,j=[],g=!1,O=!1;const m=(e,t)=>!!e&&i.call(e,t),B=e=>"Object"===o(e),x=e=>{j.length?r?((e,t,r)=>{if("vue"===n&&c.$set&&!m(e,t[0]))return;const{$set:i=((e,t,n)=>{e[t]=n})}=c,o="react"===n,s=o?{...e}:e;let a=s,l=!1;for(let e=0;e<t.length;e++){const n=t[e],c=m(a,n);if(e===t.length-1){const e="boolean"==typeof a[n];l=!c||e,l&&i(a,n,r)}else{if(!c&&i(a,n,{}),!B(a[n]))break;o&&(a[n]={...a[n]}),a=a[n]}}o&&l&&c.setState({[t[0]]:s[t[0]]})})(u,j,e):a[p]=e:(h&&(h[0][h[1]]=e),d&&d(e))},A=()=>h?h[0][h[1]]:r||"string"!=typeof p?((e,t)=>{let n=!1;if(e&&B(e)&&Array.isArray(t)&&t.length){let r=e;for(let e=0;e<t.length;e++){const i=t[e];if("object"!=typeof r||!m(r,i))break;r=r[i],e===t.length-1&&(n="boolean"==typeof r&&r)}}return n})(u,j):u[p];if(p){const e=e=>Array.isArray(e)&&2===e.length;"string"==typeof p?j=p.split("."):e(p)?h=p:"function"==typeof p&&(d=p,e(y)&&(h=y)),g=j.length>0||!!h||!!d,g&&(O=A())}let k;k="function"==typeof e?O?(()=>{const e=Promise.resolve(void 0);return Object.assign(e,{then(...t){const[n]=t;return 2===t.length&&"function"==typeof n?n(void 0):e},catch:t=>e,finally:()=>e})})():f?s(e()):e():f?s(e):e;const K=()=>x(!1);return Object.defineProperties(k,{__lockValue:{get:A},unlock:{value:K}}),g&&!O&&(x(!0),!b&&k.finally(K)),k}),"_checkLockKey",{value:e=>a[e]}),u={install(e,t="$wp"){e.config&&"globalProperties"in e.config?e.config.globalProperties[t]=l:e.prototype[t]=l}};const f=(e,t)=>{const n={};return Object.keys(e).forEach((r=>{const i=e[r];""!==i&&null!=i&&(n[r]=t&&"[object Object]"===Object.prototype.toString.call(i)?f(i):i)})),n},{toString:p}=Object.prototype,y=e=>{if(null!==e)return Array.isArray(e)?e.map(y):("[object Object]"===p.call(e)&&Object.keys(e).forEach((t=>{e[t]=y(e[t])})),e)};e.ChinaIdCardValid=function(e){const t=e.toString().toUpperCase();return r.test(t)&&["11","12","13","14","15","21","22","23","31","32","33","34","35","36","37","41","42","43","44","45","46","50","51","52","53","54","61","62","63","64","65","71","81","82","91"].includes(t.substr(0,2))&&(()=>{if(18===t.length){const e=t.split(""),n=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2],r=[1,0,"X",9,8,7,6,5,4,3,2];let i=0,c=0,o=0;for(let t=0;t<17;t++)c=parseInt(e[t]),o=n[t],i+=c*o;return r[i%11].toString()===e[17]}return!0})()},e.array2tree=function(e,r={}){const{primaryKey:i,parentKey:c,childrenKey:o,createRoot:s,parentRefKey:a}=Object.assign({primaryKey:"id",parentKey:"pid",childrenKey:"children",createRoot:!1,parentRefKey:!1},r),l=a&&("string"==typeof a?a:"_parent");let u={},f=[];return Array.isArray(e)&&e.forEach((e=>{!t.call(u,e[i])&&(u[e[i]]=Object.assign({},e,n(o))),t.call(u,e[c])&&u[e[c]][o].push(Object.assign(u[e[i]],l?{[l]:u[e[c]]}:{})),!e[c]&&f.push(u[e[i]])})),"function"==typeof s?s(f):s?{[o]:f}:f},e.awaitWrapper=s,e.byteParse=function(e,t={}){},e.byteStringify=function(e,t){const n=Object.assign({standard:"jedec",unitLvl:"auto",precision:1,detail:!1},t),{standard:r,unitLvl:i,precision:c,detail:o}=n;let s=parseFloat(e);if(!Number.isFinite(s))return;const a=s<0?-1:1;s=Math.abs(s);const{base:l,unitMap:u}=((e,t)=>{const n={B:{expMax:0,units:{metric:"B",iec:"B",jedec:"B"}},K:{expMax:1,units:{metric:"kB",iec:"KiB",jedec:"KB"}},M:{expMax:2,units:{metric:"MB",iec:"MiB",jedec:"MB"}},G:{expMax:3,units:{metric:"GB",iec:"GiB",jedec:"GB"}},T:{expMax:4,units:{metric:"TB",iec:"TiB",jedec:"TB"}},P:{expMax:5,units:{metric:"PB",iec:"PiB",jedec:"PB"}},E:{expMax:6,units:{metric:"EB",iec:"EiB",jedec:"EB"}},Z:{expMax:7,units:{metric:"ZB",iec:"ZiB",jedec:"ZB"}},Y:{expMax:8,units:{metric:"YB",iec:"YiB",jedec:"YB"}}},r={metric:1e3,iec:1024,jedec:1024};return{base:r[e]||r.jedec,unitMap:n[t]||Object.values(n)}})(r,i),f=e=>Number.isInteger(e)?e:e.toFixed(c);let p="",y=0;if(Array.isArray(u))u.some((e=>{const t=Math.pow(l,e.expMax),n=s/t;return!(n>l)&&(p=e.units[r],y=f(n*a),!0)}));else{const e=Math.pow(l,u.expMax);p=u.units[r];y=f(s/e*a)}return o?{value:y,unit:p}:`${y} ${p}`},e.checkoutBy=function(e,t,n){return e instanceof Object?Array.isArray(t)?t.map((t=>e[t])):t&&t instanceof Object?Object.keys(t).map((r=>e[r]instanceof Object&&t[r]instanceof Object?n?n({},e[r],t[r]):Object.assign({},e[r],t[r]):t[r]||e[r])):Object.values(e):[]},e.filterNullable=f,e.formParamsSwitch=(e,t,n)=>{const r=Object.keys(t),i={},c={};Object.keys(e).forEach((t=>{r.includes(t)?i[t]=e[t]:c[t]=e[t]}));const o=Object.keys(i);if(0===o.length)return e;const{filterNullable:s,dateFormat:a}={filterNullable:!0,...n},l=o.reduce(((e,n)=>{const r=i[n];if(!r)return e;const c=t[n];if("join"===c||"pop"===c)Array.isArray(r)&&r.length&&(e[n]="join"===c?r.join(","):r.slice(-1)[0]);else if(2===c.length||3===c.length){if(!r||2!==r.length)return e;const[t,n,i]=c,[o,s]=r;Object.assign(e,{[t]:a instanceof Function?a(o,i):o,[n]:a instanceof Function?a(s,i):s})}return e}),{}),u={...c,...l};return s?f(u):u},e.formulaValidate=function(e,t){return e=e.replace(/\s/g,""),!/[+\-*/]{2,}/.test(e)&&!/\(\)/.test(e)&&!/\([+\-*/]/.test(e)&&!/[+\-*/]\)/.test(e)&&!/[^+\-*/]\(/.test(e)&&!/\)[^+\-*/]/.test(e)&&(()=>{let t=[];for(let n,r=0;r<e.length;r++)if(n=e.charAt(r),"("===n)t.push("(");else if(")"===n){if(!(t.length>0))return!1;t.pop()}return!t.length})()&&(!Array.isArray(t)||(n=t,e.replace(/[()+\-*/]{1,}/g,"`").split("`").every((e=>!/[A-Z]/i.test(e)||n.includes(e)))));var n},e.isNullable=e=>""===e||null==e,e.mapToObject=function(e,t="key",n="value"){let r={};return Array.isArray(e)&&t&&n&&[t,n].every((e=>["string","function"].includes(typeof e)))&&e.forEach(((e,i)=>{const c="string"==typeof t?e[t]:t(e,i),o="string"==typeof n?e[n]:n(e,i);["string","number"].includes(typeof c)&&(r[c]=o)})),r},e.objType=o,e.pickRenameKeys=function(e,t){if(!(e&&e instanceof Object&&t&&t instanceof Object))return;let n={};for(let r in e)r in t&&(n[t[r]]=e[r]);return n},e.safeJsonParse=function(e="",t){try{return JSON.parse(e)}catch(e){return t}},e.switchNullToUndefined=y,e.tree2array=function(e,t={}){const{primaryKey:r,parentKey:i,childrenKey:c,hasParentKey:o,returnObject:s}=Object.assign({hasParentKey:!0,primaryKey:"id",parentKey:"pid",childrenKey:"children",returnObject:!1},t);let a=s?{}:[];return Array.isArray(e)||"object"==typeof e?(function e(t,n,l=!1){let u=o?{}:{[i]:n};if(!l){const e=Object.assign(u,function(e,t){let n={};for(let r in e)r!==t&&(n[r]=e[r]);return n}(t,c));s?a[t[r]]=e:a.push(e)}Array.isArray(t[c])&&t[c].length&&t[c].forEach((n=>e(n,t[r])))}(Array.isArray(e)?n(c,e):e,null,!0),a):a},e.wp=l,e.wpVuePlugin=u,Object.defineProperty(e,"__esModule",{value:!0})}));
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Smartfetch={})}(this,(function(e){"use strict";const{hasOwnProperty:t}=Object.prototype;function n(e,t=[]){return{[e]:t}}const r=/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;const{hasOwnProperty:i,toString:c}=Object.prototype,o=e=>{const t=c.call(e).match(/^\[object (.*)\]$/);return t?t[1]:""};async function s(e){try{return[null,await e]}catch(e){return[e,void 0]}}const a={};function l(e,t){const n=function(e){return e?e._isVue||e.$&&e.$.vnode?"vue":"setState"in e?"react":"unknown":"unknown"}(this),r="unknown"!==n,c=r?this:a,l="react"===n?"state":"",u=l?c[l]:c,{wrap:f,lock:p,syncRefHandle:y,manualUnlock:b}="boolean"==typeof t?{wrap:t}:{...t};let d,h,j=[],g=!1,O=!1;const m=(e,t)=>!!e&&i.call(e,t),B=e=>"Object"===o(e),x=e=>{j.length?r?((e,t,r)=>{if("vue"===n&&c.$set&&!m(e,t[0]))return;const{$set:i=((e,t,n)=>{e[t]=n})}=c,o="react"===n,s=o?{...e}:e;let a=s,l=!1;for(let e=0;e<t.length;e++){const n=t[e],c=m(a,n);if(e===t.length-1){const e="boolean"==typeof a[n];l=!c||e,l&&i(a,n,r)}else{if(!c&&i(a,n,{}),!B(a[n]))break;o&&(a[n]={...a[n]}),a=a[n]}}o&&l&&c.setState({[t[0]]:s[t[0]]})})(u,j,e):a[p]=e:(h&&(h[0][h[1]]=e),d&&d(e))},A=()=>h?h[0][h[1]]:r||"string"!=typeof p?((e,t)=>{let n=!1;if(e&&B(e)&&Array.isArray(t)&&t.length){let r=e;for(let e=0;e<t.length;e++){const i=t[e];if("object"!=typeof r||!m(r,i))break;r=r[i],e===t.length-1&&(n="boolean"==typeof r&&r)}}return n})(u,j):u[p];if(p){const e=e=>Array.isArray(e)&&2===e.length;"string"==typeof p?j=p.split("."):e(p)?h=p:"function"==typeof p&&(d=p,e(y)&&(h=y)),g=j.length>0||!!h||!!d,g&&(O=A())}let k;k="function"==typeof e?O?(()=>{const e=Promise.resolve(void 0);return Object.assign(e,{then(...t){const[n]=t;return 2===t.length&&"function"==typeof n?n(void 0):e},catch:t=>e,finally:()=>e})})():f?s(e()):e():f?s(e):e;const K=()=>x(!1);return Object.defineProperties(k,{__lockValue:{get:A},_checkLockKey:{value:e=>a[e]},unlock:{value:K}}),g&&!O&&(x(!0),!b&&k.finally(K)),k}const u=Object.defineProperty(l,"_checkLockKey",{value:e=>a[e]}),f={install(e,t="$wp"){e.config&&"globalProperties"in e.config?e.config.globalProperties[t]=l:e.prototype[t]=l}};const p=(e,t)=>{const n={};return Object.keys(e).forEach((r=>{const i=e[r];""!==i&&null!=i&&(n[r]=t&&"[object Object]"===Object.prototype.toString.call(i)?p(i):i)})),n},{toString:y}=Object.prototype,b=e=>{if(null!==e)return Array.isArray(e)?e.map(b):("[object Object]"===y.call(e)&&Object.keys(e).forEach((t=>{e[t]=b(e[t])})),e)};e.ChinaIdCardValid=function(e){const t=e.toString().toUpperCase();return r.test(t)&&["11","12","13","14","15","21","22","23","31","32","33","34","35","36","37","41","42","43","44","45","46","50","51","52","53","54","61","62","63","64","65","71","81","82","91"].includes(t.substr(0,2))&&(()=>{if(18===t.length){const e=t.split(""),n=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2],r=[1,0,"X",9,8,7,6,5,4,3,2];let i=0,c=0,o=0;for(let t=0;t<17;t++)c=parseInt(e[t]),o=n[t],i+=c*o;return r[i%11].toString()===e[17]}return!0})()},e.array2tree=function(e,r={}){const{primaryKey:i,parentKey:c,childrenKey:o,createRoot:s,parentRefKey:a}=Object.assign({primaryKey:"id",parentKey:"pid",childrenKey:"children",createRoot:!1,parentRefKey:!1},r),l=a&&("string"==typeof a?a:"_parent");let u={},f=[];return Array.isArray(e)&&e.forEach((e=>{!t.call(u,e[i])&&(u[e[i]]=Object.assign({},e,n(o))),t.call(u,e[c])&&u[e[c]][o].push(Object.assign(u[e[i]],l?{[l]:u[e[c]]}:{})),!e[c]&&f.push(u[e[i]])})),"function"==typeof s?s(f):s?{[o]:f}:f},e.awaitWrapper=s,e.byteParse=function(e,t={}){},e.byteStringify=function(e,t){const n=Object.assign({standard:"jedec",unitLvl:"auto",precision:1,detail:!1},t),{standard:r,unitLvl:i,precision:c,detail:o}=n;let s=parseFloat(e);if(!Number.isFinite(s))return;const a=s<0?-1:1;s=Math.abs(s);const{base:l,unitMap:u}=((e,t)=>{const n={B:{expMax:0,units:{metric:"B",iec:"B",jedec:"B"}},K:{expMax:1,units:{metric:"kB",iec:"KiB",jedec:"KB"}},M:{expMax:2,units:{metric:"MB",iec:"MiB",jedec:"MB"}},G:{expMax:3,units:{metric:"GB",iec:"GiB",jedec:"GB"}},T:{expMax:4,units:{metric:"TB",iec:"TiB",jedec:"TB"}},P:{expMax:5,units:{metric:"PB",iec:"PiB",jedec:"PB"}},E:{expMax:6,units:{metric:"EB",iec:"EiB",jedec:"EB"}},Z:{expMax:7,units:{metric:"ZB",iec:"ZiB",jedec:"ZB"}},Y:{expMax:8,units:{metric:"YB",iec:"YiB",jedec:"YB"}}},r={metric:1e3,iec:1024,jedec:1024};return{base:r[e]||r.jedec,unitMap:n[t]||Object.values(n)}})(r,i),f=e=>Number.isInteger(e)?e:e.toFixed(c);let p="",y=0;if(Array.isArray(u))u.some((e=>{const t=Math.pow(l,e.expMax),n=s/t;return!(n>l)&&(p=e.units[r],y=f(n*a),!0)}));else{const e=Math.pow(l,u.expMax);p=u.units[r];y=f(s/e*a)}return o?{value:y,unit:p}:`${y} ${p}`},e.checkoutBy=function(e,t,n){return e instanceof Object?Array.isArray(t)?t.map((t=>e[t])):t&&t instanceof Object?Object.keys(t).map((r=>e[r]instanceof Object&&t[r]instanceof Object?n?n({},e[r],t[r]):Object.assign({},e[r],t[r]):t[r]||e[r])):Object.values(e):[]},e.filterNullable=p,e.formParamsSwitch=(e,t,n)=>{const r=Object.keys(t),i={},c={};Object.keys(e).forEach((t=>{r.includes(t)?i[t]=e[t]:c[t]=e[t]}));const o=Object.keys(i);if(0===o.length)return e;const{filterNullable:s,dateFormat:a}={filterNullable:!0,...n},l=o.reduce(((e,n)=>{const r=i[n];if(!r)return e;const c=t[n];if("join"===c||"pop"===c)Array.isArray(r)&&r.length&&(e[n]="join"===c?r.join(","):r.slice(-1)[0]);else if(2===c.length||3===c.length){if(!r||2!==r.length)return e;const[t,n,i]=c,[o,s]=r;Object.assign(e,{[t]:a instanceof Function?a(o,i):o,[n]:a instanceof Function?a(s,i):s})}return e}),{}),u={...c,...l};return s?p(u):u},e.formulaValidate=function(e,t){return e=e.replace(/\s/g,""),!/[+\-*/]{2,}/.test(e)&&!/\(\)/.test(e)&&!/\([+\-*/]/.test(e)&&!/[+\-*/]\)/.test(e)&&!/[^+\-*/]\(/.test(e)&&!/\)[^+\-*/]/.test(e)&&(()=>{let t=[];for(let n,r=0;r<e.length;r++)if(n=e.charAt(r),"("===n)t.push("(");else if(")"===n){if(!(t.length>0))return!1;t.pop()}return!t.length})()&&(!Array.isArray(t)||(n=t,e.replace(/[()+\-*/]{1,}/g,"`").split("`").every((e=>!/[A-Z]/i.test(e)||n.includes(e)))));var n},e.isNullable=e=>""===e||null==e,e.mapToObject=function(e,t="key",n="value"){let r={};return Array.isArray(e)&&t&&n&&[t,n].every((e=>["string","function"].includes(typeof e)))&&e.forEach(((e,i)=>{const c="string"==typeof t?e[t]:t(e,i),o="string"==typeof n?e[n]:n(e,i);["string","number"].includes(typeof c)&&(r[c]=o)})),r},e.objType=o,e.pickRenameKeys=function(e,t){if(!(e&&e instanceof Object&&t&&t instanceof Object))return;let n={};for(let r in e)r in t&&(n[t[r]]=e[r]);return n},e.safeJsonParse=function(e="",t){try{return JSON.parse(e)}catch(e){return t}},e.switchNullToUndefined=b,e.tree2array=function(e,t={}){const{primaryKey:r,parentKey:i,childrenKey:c,hasParentKey:o,returnObject:s}=Object.assign({hasParentKey:!0,primaryKey:"id",parentKey:"pid",childrenKey:"children",returnObject:!1},t);let a=s?{}:[];return Array.isArray(e)||"object"==typeof e?(function e(t,n,l=!1){let u=o?{}:{[i]:n};if(!l){const e=Object.assign(u,function(e,t){let n={};for(let r in e)r!==t&&(n[r]=e[r]);return n}(t,c));s?a[t[r]]=e:a.push(e)}Array.isArray(t[c])&&t[c].length&&t[c].forEach((n=>e(n,t[r])))}(Array.isArray(e)?n(c,e):e,null,!0),a):a},e.wp=u,e.wpVuePlugin=f,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wxhccc/es-util v1.5.0
2
+ * @wxhccc/es-util v1.5.1
3
3
  * (c) 2021 wxhccc
4
4
  * @license MIT
5
5
  */
@@ -39,7 +39,7 @@ export declare type ParamsSwitchMaps<DK extends string = string, RK extends stri
39
39
  * @param filterNullableValue 是否需要过滤掉空数据项
40
40
  */
41
41
  export declare const formParamsSwitch: <T extends AnyObject, R extends AnyObject = AnyObject>(formData: T, maps: ParamsSwitchMaps, options?: {
42
- filterNullable: boolean;
43
- dateFormat: (date: unknown, format?: string | undefined) => string;
42
+ filterNullable?: boolean | undefined;
43
+ dateFormat?: ((date: any, format?: string | undefined) => string) | undefined;
44
44
  } | undefined) => R;
45
45
  export {};
package/dist/promise.d.ts CHANGED
@@ -23,10 +23,17 @@ export interface WpOptions {
23
23
  syncRefHandle?: SyncRefHandle;
24
24
  manualUnlock?: boolean;
25
25
  }
26
- declare type WpReturn<T> = PromiseWithLock<T | undefined | [null, T] | [Error, undefined]>;
26
+ declare type WpReturn<T> = PromiseWithLock<T | undefined>;
27
+ declare type WpArrReturn<T> = PromiseWithLock<[null, T] | [Error, undefined]>;
27
28
  declare type WpPromise<T> = Promise<T> | (() => Promise<T>);
28
- declare function wrapPromise<T>(this: any, promise: WpPromise<T>, wrap?: boolean): WpReturn<T>;
29
- declare function wrapPromise<T>(this: any, promise: WpPromise<T>, options?: WpOptions): WpReturn<T>;
29
+ declare function wrapPromise<T>(this: any, promise: WpPromise<T>, wrap?: false): WpReturn<T>;
30
+ declare function wrapPromise<T>(this: any, promise: WpPromise<T>, wrap: true): WpArrReturn<T>;
31
+ declare function wrapPromise<T>(this: any, promise: WpPromise<T>, options?: WpOptions & {
32
+ wrap?: false;
33
+ }): WpReturn<T>;
34
+ declare function wrapPromise<T>(this: any, promise: WpPromise<T>, options?: WpOptions & {
35
+ wrap: true;
36
+ }): WpArrReturn<T>;
30
37
  declare type WP = typeof wrapPromise & {
31
38
  _checkLockKey: (key: string) => boolean;
32
39
  };
package/dist/promise.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wxhccc/es-util v1.5.0
2
+ * @wxhccc/es-util v1.5.1
3
3
  * (c) 2021 wxhccc
4
4
  * @license MIT
5
5
  */
@@ -158,6 +158,7 @@ function wrapPromise(promise, wrapOrOptions) {
158
158
  const unlock = () => stateLock(false);
159
159
  Object.defineProperties(corePromsie, {
160
160
  '__lockValue': { get: checkLock },
161
+ _checkLockKey: { value: (key) => lockCtx[key] },
161
162
  unlock: { value: unlock }
162
163
  });
163
164
  if (needLock && !ignoreLock) {
@@ -170,10 +171,10 @@ const wp = Object.defineProperty(wrapPromise, '_checkLockKey', { value: (key) =>
170
171
  const wpVuePlugin = {
171
172
  install(appOrVue, key = '$wp') {
172
173
  if (appOrVue.config && 'globalProperties' in appOrVue.config) {
173
- appOrVue.config.globalProperties[key] = wp;
174
+ appOrVue.config.globalProperties[key] = wrapPromise;
174
175
  }
175
176
  else {
176
- appOrVue.prototype[key] = wp;
177
+ appOrVue.prototype[key] = wrapPromise;
177
178
  }
178
179
  }
179
180
  };
package/dist/validate.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wxhccc/es-util v1.5.0
2
+ * @wxhccc/es-util v1.5.1
3
3
  * (c) 2021 wxhccc
4
4
  * @license MIT
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @wxhccc/es-util v1.5.0
2
+ * @wxhccc/es-util v1.5.1
3
3
  * (c) 2021 wxhccc
4
4
  * @license MIT
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxhccc/es-util",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "A library that contains some useful methods",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -39,7 +39,7 @@ export declare type ParamsSwitchMaps<DK extends string = string, RK extends stri
39
39
  * @param filterNullableValue 是否需要过滤掉空数据项
40
40
  */
41
41
  export declare const formParamsSwitch: <T extends AnyObject, R extends AnyObject = AnyObject>(formData: T, maps: ParamsSwitchMaps, options?: {
42
- filterNullable: boolean;
43
- dateFormat: (date: unknown, format?: string | undefined) => string;
42
+ filterNullable?: boolean | undefined;
43
+ dateFormat?: ((date: any, format?: string | undefined) => string) | undefined;
44
44
  } | undefined) => R;
45
45
  export {};