@wltech/libs
Advanced tools
Comparing version 0.0.0-dev.4 to 0.0.0-dev.5
@@ -125,6 +125,7 @@ 'use strict'; | ||
return func.apply(void 0, args).then(function (res) { | ||
if (res.clone && typeof res.clone === 'function') { | ||
cache[apiKey] = res.clone(); | ||
} else { | ||
cache[apiKey] = res; | ||
// 缓存原始数据,或者clone数据,不能return 同一份数据,会被释放 | ||
cache[apiKey] = res; | ||
if (res && typeof res.clone === 'function') { | ||
// fetch 缓存,不能把原始数据return,否则会被释放 | ||
return res.clone(); | ||
} | ||
@@ -131,0 +132,0 @@ return cache[apiKey]; |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return"object"!=typeof e&&"function"!=typeof e||null===e}function t(t){return e(t)?t:JSON.stringify(t,(function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce((function(e,n){return e[n]=t[n],e}),{})}))}function n(e){if(null===e||"object"!=typeof e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e)){for(var t=[],r=0;r<e.length;r++)t[r]=n(e[r]);return t}if("object"==typeof e){var o={};for(var i in e)e.hasOwnProperty(i)&&(o[i]=n(e[i]));return o}return e}Object.defineProperty(exports,"__esModule",{value:!0});var r={},o={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"}};exports.cloneDeep=n,exports.generateDeterministicUniqueKey=t,exports.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},exports.isPrimitive=e,exports.wrapFunctionWithCache=function(e,i){return void 0===i&&(i=o),function(){for(var u=arguments.length,f=new Array(u),l=0;l<u;l++)f[l]=arguments[l];var c=t(f);if(r[c])return Promise.resolve(n(r[c]));var a=c+"_wl_loading";if(r[a]){var s=Object.assign({},o,i);return new Promise((function(e){var t=Date.now(),o=setInterval((function(){r[c]?(clearInterval(o),e(n(r[c]))):Date.now()-t>s.timeout&&(clearInterval(o),e(n(s.timeoutResult)))}),100)}))}return r[a]=!0,e.apply(void 0,f).then((function(e){return r[c]=e.clone&&"function"==typeof e.clone?e.clone():e,r[c]})).catch((function(e){throw e})).finally((function(){r[a]=!1}))}}; | ||
"use strict";function e(e){return"object"!=typeof e&&"function"!=typeof e||null===e}function t(t){return e(t)?t:JSON.stringify(t,(function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce((function(e,n){return e[n]=t[n],e}),{})}))}function n(e){if(null===e||"object"!=typeof e)return e;if("function"==typeof e.clone)return e.clone();if(Array.isArray(e)){for(var t=[],r=0;r<e.length;r++)t[r]=n(e[r]);return t}if("object"==typeof e){var o={};for(var i in e)e.hasOwnProperty(i)&&(o[i]=n(e[i]));return o}return e}Object.defineProperty(exports,"__esModule",{value:!0});var r={},o={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"}};exports.cloneDeep=n,exports.generateDeterministicUniqueKey=t,exports.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},exports.isPrimitive=e,exports.wrapFunctionWithCache=function(e,i){return void 0===i&&(i=o),function(){for(var u=arguments.length,f=new Array(u),l=0;l<u;l++)f[l]=arguments[l];var c=t(f);if(r[c])return Promise.resolve(n(r[c]));var a=c+"_wl_loading";if(r[a]){var s=Object.assign({},o,i);return new Promise((function(e){var t=Date.now(),o=setInterval((function(){r[c]?(clearInterval(o),e(n(r[c]))):Date.now()-t>s.timeout&&(clearInterval(o),e(n(s.timeoutResult)))}),100)}))}return r[a]=!0,e.apply(void 0,f).then((function(e){return r[c]=e,e&&"function"==typeof e.clone?e.clone():r[c]})).catch((function(e){throw e})).finally((function(){r[a]=!1}))}}; | ||
//# sourceMappingURL=libs.cjs.production.min.js.map |
@@ -121,6 +121,7 @@ // 获取全局对象 | ||
return func.apply(void 0, args).then(function (res) { | ||
if (res.clone && typeof res.clone === 'function') { | ||
cache[apiKey] = res.clone(); | ||
} else { | ||
cache[apiKey] = res; | ||
// 缓存原始数据,或者clone数据,不能return 同一份数据,会被释放 | ||
cache[apiKey] = res; | ||
if (res && typeof res.clone === 'function') { | ||
// fetch 缓存,不能把原始数据return,否则会被释放 | ||
return res.clone(); | ||
} | ||
@@ -127,0 +128,0 @@ return cache[apiKey]; |
{ | ||
"name": "@wltech/libs", | ||
"author": "zhyswan", | ||
"version": "0.0.0-dev.4", | ||
"version": "0.0.0-dev.5", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -57,8 +57,9 @@ // import { getGlobal } from './getGlobal'; | ||
.then(res => { | ||
if ((res as any).clone && typeof (res as any).clone === 'function') { | ||
cache[apiKey] = (res as any).clone(); | ||
} else { | ||
cache[apiKey] = res; | ||
// 缓存原始数据,或者clone数据,不能return 同一份数据,会被释放 | ||
cache[apiKey] = res; | ||
if (res && typeof (res as any).clone === 'function') { | ||
// fetch 缓存,不能把原始数据return,否则会被释放 | ||
return (res as any).clone(); | ||
} | ||
return cache[apiKey] as T; | ||
return cache[apiKey]; | ||
}) | ||
@@ -65,0 +66,0 @@ .catch((error: any) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42630
454