+5
-0
@@ -25,2 +25,7 @@ export { merge } from 'ts-deepmerge'; | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -27,0 +32,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
+5
-0
@@ -25,2 +25,7 @@ export { merge } from 'ts-deepmerge'; | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -27,0 +32,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -25,2 +25,7 @@ export { merge } from 'ts-deepmerge'; | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -27,0 +32,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -25,2 +25,7 @@ export { merge } from 'ts-deepmerge'; | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -27,0 +32,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
+1
-1
| { | ||
| "name": "xior", | ||
| "version": "0.1.2", | ||
| "version": "0.1.3", | ||
| "description": "A lite request lib based on **fetch** with plugins support, and axios similar API", | ||
@@ -5,0 +5,0 @@ "repository": "suhaotian/xior", |
@@ -1,1 +0,1 @@ | ||
| Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tiny-lru");function t(e,t,n,r,u,i,o){try{var l=e[i](o),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,u)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(u,i){var o=e.apply(n,r);function l(e){t(o,u,i,l,c,"next",e)}function c(e){t(o,u,i,l,c,"throw",e)}l(void 0)})}}exports.default=function(t={}){let{enableCache:r,defaultCache:u=e.lru(100,3e5)}=t;return function(e){return n(function*(t){let{enableCache:i=r,forceUpdate:o,defaultCache:l=u,_url:c,encode:f,data:a}=t,d="GET"===t.method,s=typeof i;if("undefined"===s?d:"function"===s?i(t):!!i){let r=function(e,t,n){let r=t?n(t):"";r&&(r=e.includes("?")?e+"&"+r:e+"?"+r);let[u,i]=r.split("?");if(i){let e=i.split("&");return`${u}?${e.sort().join("&")}`}return r||e}(c,a,f),u=l.get(r);return!u||o?(u=n(function*(){try{return yield e(t)}catch(e){throw"delete"in l?l.delete(r):l.del(r),e}})(),l.set(r,u),u):u.then(e=>(e.fromCache=!0,e))}return e(t)})}}; | ||
| Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tiny-lru");function t(e,t,n,r,u,i,o){try{var l=e[i](o),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,u)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(u,i){var o=e.apply(n,r);function l(e){t(o,u,i,l,c,"next",e)}function c(e){t(o,u,i,l,c,"throw",e)}l(void 0)})}}exports.default=function(t={}){let{enableCache:r,defaultCache:u=e.lru(100,3e5)}=t;return function(e){return n(function*(t){let{enableCache:i=r,forceUpdate:o,defaultCache:l=u,_url:c,encode:f,data:a}=t,d="GET"===t.method||t.isGet,s=typeof i;if("undefined"===s?d:"function"===s?i(t):!!i){let r=function(e,t,n){let r=t?n(t):"";r&&(r=e.includes("?")?e+"&"+r:e+"?"+r);let[u,i]=r.split("?");if(i){let e=i.split("&");return`${u}?${e.sort().join("&")}`}return r||e}(c,a,f),u=l.get(r);return!u||o?(u=n(function*(){try{return yield e(t)}catch(e){throw"delete"in l?l.delete(r):l.del(r),e}})(),l.set(r,u),u):u.then(e=>(e.fromCache=!0,e))}return e(t)})}}; |
@@ -32,2 +32,7 @@ type ICacheLike<T> = { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -34,0 +39,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -32,2 +32,7 @@ type ICacheLike<T> = { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -34,0 +39,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -32,2 +32,7 @@ type ICacheLike<T> = { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -34,0 +39,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -32,2 +32,7 @@ type ICacheLike<T> = { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -34,0 +39,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -1,1 +0,1 @@ | ||
| import{lru as t}from"tiny-lru";function e(t,e,n,r,i,u,o){try{var c=t[u](o),l=c.value}catch(t){n(t);return}c.done?e(l):Promise.resolve(l).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,u){var o=t.apply(n,r);function c(t){e(o,i,u,c,l,"next",t)}function l(t){e(o,i,u,c,l,"throw",t)}c(void 0)})}}function r(e={}){let{enableCache:r,defaultCache:i=t(100,3e5)}=e;return function(t){return n(function*(e){let{enableCache:u=r,forceUpdate:o,defaultCache:c=i,_url:l,encode:f,data:a}=e,d="GET"===e.method,h=typeof u;if("undefined"===h?d:"function"===h?u(e):!!u){let r=function(t,e,n){let r=e?n(e):"";r&&(r=t.includes("?")?t+"&"+r:t+"?"+r);let[i,u]=r.split("?");if(u){let t=u.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(l,a,f),i=c.get(r);return!i||o?(i=n(function*(){try{return yield t(e)}catch(t){throw"delete"in c?c.delete(r):c.del(r),t}})(),c.set(r,i),i):i.then(t=>(t.fromCache=!0,t))}return t(e)})}}export{r as default}; | ||
| import{lru as t}from"tiny-lru";function e(t,e,n,r,i,u,o){try{var c=t[u](o),l=c.value}catch(t){n(t);return}c.done?e(l):Promise.resolve(l).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,u){var o=t.apply(n,r);function c(t){e(o,i,u,c,l,"next",t)}function l(t){e(o,i,u,c,l,"throw",t)}c(void 0)})}}function r(e={}){let{enableCache:r,defaultCache:i=t(100,3e5)}=e;return function(t){return n(function*(e){let{enableCache:u=r,forceUpdate:o,defaultCache:c=i,_url:l,encode:f,data:a}=e,d="GET"===e.method||e.isGet,h=typeof u;if("undefined"===h?d:"function"===h?u(e):!!u){let r=function(t,e,n){let r=e?n(e):"";r&&(r=t.includes("?")?t+"&"+r:t+"?"+r);let[i,u]=r.split("?");if(u){let t=u.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(l,a,f),i=c.get(r);return!i||o?(i=n(function*(){try{return yield t(e)}catch(t){throw"delete"in c?c.delete(r):c.del(r),t}})(),c.set(r,i),i):i.then(t=>(t.fromCache=!0,t))}return t(e)})}}export{r as default}; |
@@ -1,1 +0,1 @@ | ||
| import{lru as t}from"tiny-lru";function e(t,e,n,r,i,u,o){try{var c=t[u](o),l=c.value}catch(t){n(t);return}c.done?e(l):Promise.resolve(l).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,u){var o=t.apply(n,r);function c(t){e(o,i,u,c,l,"next",t)}function l(t){e(o,i,u,c,l,"throw",t)}c(void 0)})}}function r(e={}){let{enableCache:r,defaultCache:i=t(100,3e5)}=e;return function(t){return n(function*(e){let{enableCache:u=r,forceUpdate:o,defaultCache:c=i,_url:l,encode:f,data:a}=e,d="GET"===e.method,h=typeof u;if("undefined"===h?d:"function"===h?u(e):!!u){let r=function(t,e,n){let r=e?n(e):"";r&&(r=t.includes("?")?t+"&"+r:t+"?"+r);let[i,u]=r.split("?");if(u){let t=u.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(l,a,f),i=c.get(r);return!i||o?(i=n(function*(){try{return yield t(e)}catch(t){throw"delete"in c?c.delete(r):c.del(r),t}})(),c.set(r,i),i):i.then(t=>(t.fromCache=!0,t))}return t(e)})}}export{r as default}; | ||
| import{lru as t}from"tiny-lru";function e(t,e,n,r,i,u,o){try{var c=t[u](o),l=c.value}catch(t){n(t);return}c.done?e(l):Promise.resolve(l).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,u){var o=t.apply(n,r);function c(t){e(o,i,u,c,l,"next",t)}function l(t){e(o,i,u,c,l,"throw",t)}c(void 0)})}}function r(e={}){let{enableCache:r,defaultCache:i=t(100,3e5)}=e;return function(t){return n(function*(e){let{enableCache:u=r,forceUpdate:o,defaultCache:c=i,_url:l,encode:f,data:a}=e,d="GET"===e.method||e.isGet,h=typeof u;if("undefined"===h?d:"function"===h?u(e):!!u){let r=function(t,e,n){let r=e?n(e):"";r&&(r=t.includes("?")?t+"&"+r:t+"?"+r);let[i,u]=r.split("?");if(u){let t=u.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(l,a,f),i=c.get(r);return!i||o?(i=n(function*(){try{return yield t(e)}catch(t){throw"delete"in c?c.delete(r):c.del(r),t}})(),c.set(r,i),i):i.then(t=>(t.fromCache=!0,t))}return t(e)})}}export{r as default}; |
@@ -1,1 +0,1 @@ | ||
| Object.defineProperty(exports,"__esModule",{value:!0}),require("ts-deepmerge");class e extends Error{constructor(e,t,r){super(e),this.request=t,this.config=t,this.response=r}}class t extends e{}function r(e,t,r,n,o,i,u){try{var s=e[i](u),c=s.value}catch(e){r(e);return}s.done?t(c):Promise.resolve(c).then(n,o)}function n(e){return function(){var t=this,n=arguments;return new Promise(function(o,i){var u=e.apply(t,n);function s(e){r(u,o,i,s,c,"next",e)}function c(e){r(u,o,i,s,c,"throw",e)}s(void 0)})}}exports.default=function(r={}){let{retryTimes:o,retryInterval:i,enableRetry:u}=r||{retryTimes:2,retryInterval:3e3};return function(r){return n(function*(s){let{retryTimes:c=o,retryInterval:f=i,enableRetry:a=u}=s,l=0;function y(){return d.apply(this,arguments)}function d(){return(d=n(function*(){try{return yield r(s)}catch(r){if(r instanceof e||r instanceof t){let e="GET"===s.method,t=typeof a,n="undefined"===t?e:"function"===t?a(s,r):!!a;if(c===l||!n)throw r;return f&&f>0&&l>0&&(yield new Promise(e=>{setTimeout(()=>{e("ok")},f)})),l++,y()}throw r}})).apply(this,arguments)}return y()})}}; | ||
| Object.defineProperty(exports,"__esModule",{value:!0}),require("ts-deepmerge");class e extends Error{constructor(e,t,r){super(e),this.request=t,this.config=t,this.response=r}}class t extends e{}function r(e,t,r,n,i,o,u){try{var s=e[o](u),c=s.value}catch(e){r(e);return}s.done?t(c):Promise.resolve(c).then(n,i)}function n(e){return function(){var t=this,n=arguments;return new Promise(function(i,o){var u=e.apply(t,n);function s(e){r(u,i,o,s,c,"next",e)}function c(e){r(u,i,o,s,c,"throw",e)}s(void 0)})}}exports.default=function(r={}){let{retryTimes:i,retryInterval:o,enableRetry:u}=r||{retryTimes:2,retryInterval:3e3};return function(r){return n(function*(s){let{retryTimes:c=i,retryInterval:f=o,enableRetry:a=u}=s,l=0;function y(){return d.apply(this,arguments)}function d(){return(d=n(function*(){try{return yield r(s)}catch(r){if(r instanceof e||r instanceof t){let e="GET"===s.method||s.isGet,t=typeof a,n="undefined"===t?e:"function"===t?a(s,r):!!a;if(c===l||!n)throw r;return f&&f>0&&l>0&&(yield new Promise(e=>{setTimeout(()=>{e("ok")},f)})),l++,y()}throw r}})).apply(this,arguments)}return y()})}}; |
@@ -23,2 +23,7 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -25,0 +30,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -23,2 +23,7 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -25,0 +30,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -23,2 +23,7 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -25,0 +30,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -23,2 +23,7 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -25,0 +30,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -1,1 +0,1 @@ | ||
| import"ts-deepmerge";class t extends Error{constructor(t,e,r){super(t),this.request=e,this.config=e,this.response=r}}class e extends t{}function r(t,e,r,n,i,o,u){try{var s=t[o](u),c=s.value}catch(t){r(t);return}s.done?e(c):Promise.resolve(c).then(n,i)}function n(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){var u=t.apply(e,n);function s(t){r(u,i,o,s,c,"next",t)}function c(t){r(u,i,o,s,c,"throw",t)}s(void 0)})}}function i(r={}){let{retryTimes:i,retryInterval:o,enableRetry:u}=r||{retryTimes:2,retryInterval:3e3};return function(r){return n(function*(s){let{retryTimes:c=i,retryInterval:f=o,enableRetry:a=u}=s,l=0;function y(){return h.apply(this,arguments)}function h(){return(h=n(function*(){try{return yield r(s)}catch(r){if(r instanceof t||r instanceof e){let t="GET"===s.method,e=typeof a,n="undefined"===e?t:"function"===e?a(s,r):!!a;if(c===l||!n)throw r;return f&&f>0&&l>0&&(yield new Promise(t=>{setTimeout(()=>{t("ok")},f)})),l++,y()}throw r}})).apply(this,arguments)}return y()})}}export{i as default}; | ||
| import"ts-deepmerge";class t extends Error{constructor(t,e,r){super(t),this.request=e,this.config=e,this.response=r}}class e extends t{}function r(t,e,r,n,i,o,u){try{var s=t[o](u),c=s.value}catch(t){r(t);return}s.done?e(c):Promise.resolve(c).then(n,i)}function n(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){var u=t.apply(e,n);function s(t){r(u,i,o,s,c,"next",t)}function c(t){r(u,i,o,s,c,"throw",t)}s(void 0)})}}function i(r={}){let{retryTimes:i,retryInterval:o,enableRetry:u}=r||{retryTimes:2,retryInterval:3e3};return function(r){return n(function*(s){let{retryTimes:c=i,retryInterval:f=o,enableRetry:a=u}=s,l=0;function y(){return h.apply(this,arguments)}function h(){return(h=n(function*(){try{return yield r(s)}catch(r){if(r instanceof t||r instanceof e){let t="GET"===s.method||s.isGet,e=typeof a,n="undefined"===e?t:"function"===e?a(s,r):!!a;if(c===l||!n)throw r;return f&&f>0&&l>0&&(yield new Promise(t=>{setTimeout(()=>{t("ok")},f)})),l++,y()}throw r}})).apply(this,arguments)}return y()})}}export{i as default}; |
@@ -1,1 +0,1 @@ | ||
| import"ts-deepmerge";class t extends Error{constructor(t,e,r){super(t),this.request=e,this.config=e,this.response=r}}class e extends t{}function r(t,e,r,n,i,o,u){try{var s=t[o](u),c=s.value}catch(t){r(t);return}s.done?e(c):Promise.resolve(c).then(n,i)}function n(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){var u=t.apply(e,n);function s(t){r(u,i,o,s,c,"next",t)}function c(t){r(u,i,o,s,c,"throw",t)}s(void 0)})}}function i(r={}){let{retryTimes:i,retryInterval:o,enableRetry:u}=r||{retryTimes:2,retryInterval:3e3};return function(r){return n(function*(s){let{retryTimes:c=i,retryInterval:f=o,enableRetry:a=u}=s,l=0;function y(){return h.apply(this,arguments)}function h(){return(h=n(function*(){try{return yield r(s)}catch(r){if(r instanceof t||r instanceof e){let t="GET"===s.method,e=typeof a,n="undefined"===e?t:"function"===e?a(s,r):!!a;if(c===l||!n)throw r;return f&&f>0&&l>0&&(yield new Promise(t=>{setTimeout(()=>{t("ok")},f)})),l++,y()}throw r}})).apply(this,arguments)}return y()})}}export{i as default}; | ||
| import"ts-deepmerge";class t extends Error{constructor(t,e,r){super(t),this.request=e,this.config=e,this.response=r}}class e extends t{}function r(t,e,r,n,i,o,u){try{var s=t[o](u),c=s.value}catch(t){r(t);return}s.done?e(c):Promise.resolve(c).then(n,i)}function n(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){var u=t.apply(e,n);function s(t){r(u,i,o,s,c,"next",t)}function c(t){r(u,i,o,s,c,"throw",t)}s(void 0)})}}function i(r={}){let{retryTimes:i,retryInterval:o,enableRetry:u}=r||{retryTimes:2,retryInterval:3e3};return function(r){return n(function*(s){let{retryTimes:c=i,retryInterval:f=o,enableRetry:a=u}=s,l=0;function y(){return h.apply(this,arguments)}function h(){return(h=n(function*(){try{return yield r(s)}catch(r){if(r instanceof t||r instanceof e){let t="GET"===s.method||s.isGet,e=typeof a,n="undefined"===e?t:"function"===e?a(s,r):!!a;if(c===l||!n)throw r;return f&&f>0&&l>0&&(yield new Promise(t=>{setTimeout(()=>{t("ok")},f)})),l++,y()}throw r}})).apply(this,arguments)}return y()})}}export{i as default}; |
@@ -23,2 +23,7 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -25,0 +30,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -23,2 +23,7 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -25,0 +30,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -23,2 +23,7 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -25,0 +30,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -23,2 +23,7 @@ interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -25,0 +30,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -1,1 +0,1 @@ | ||
| Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tiny-lru");function t(e,t,n,r,u,i,o){try{var l=e[i](o),a=l.value}catch(e){n(e);return}l.done?t(a):Promise.resolve(a).then(r,u)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(u,i){var o=e.apply(n,r);function l(e){t(o,u,i,l,a,"next",e)}function a(e){t(o,u,i,l,a,"throw",e)}l(void 0)})}}exports.default=function(t={}){let{enableThrottle:r,threshold:u=1e3,throttleCache:i=e.lru(10)}=t;return function(e){let t=(t,r)=>{let u=n(function*(){try{let n=yield e(r);return i.set(t,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(e){throw"delete"in i?i.delete(t):i.del(t),e}})();return i.set(t,{timestamp:Date.now(),value:u}),u};return n(function*(n){let{_url:o,encode:l,threshold:a=u,enableThrottle:f=r,data:s}=n,c="GET"===n.method,d=typeof f;if("undefined"===d?c:"function"===d?f(n):!!f){let e=function(e,t,n){let r=t?n(t):"";r&&(r=e.includes("?")?e+"&"+r:e+"?"+r);let[u,i]=r.split("?");if(i){let e=i.split("&");return`${u}?${e.sort().join("&")}`}return r||e}(o,s,l),r=Date.now(),u=i.get(e)||{timestamp:r};if(r-u.timestamp<=a){let e=u.value;if(e)return e}return t(e,n)}return e(n)})}}; | ||
| Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tiny-lru");function t(e,t,n,r,i,u,o){try{var l=e[u](o),a=l.value}catch(e){n(e);return}l.done?t(a):Promise.resolve(a).then(r,i)}function n(e){return function(){var n=this,r=arguments;return new Promise(function(i,u){var o=e.apply(n,r);function l(e){t(o,i,u,l,a,"next",e)}function a(e){t(o,i,u,l,a,"throw",e)}l(void 0)})}}exports.default=function(t={}){let{enableThrottle:r,threshold:i=1e3,throttleCache:u=e.lru(10)}=t;return function(e){let t=(t,r)=>{let i=n(function*(){try{let n=yield e(r);return u.set(t,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(e){throw"delete"in u?u.delete(t):u.del(t),e}})();return u.set(t,{timestamp:Date.now(),value:i}),i};return n(function*(n){let{_url:o,encode:l,threshold:a=i,enableThrottle:s=r,data:f}=n,c="GET"===n.method||n.isGet,d=typeof s;if("undefined"===d?c:"function"===d?s(n):!!s){let e=function(e,t,n){let r=t?n(t):"";r&&(r=e.includes("?")?e+"&"+r:e+"?"+r);let[i,u]=r.split("?");if(u){let e=u.split("&");return`${i}?${e.sort().join("&")}`}return r||e}(o,f,l),r=Date.now(),i=u.get(e)||{timestamp:r};if(r-i.timestamp<=a){let e=i.value;if(e)return e}return t(e,n)}return e(n)})}}; |
@@ -32,2 +32,7 @@ type ICacheLike<T> = { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -34,0 +39,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -32,2 +32,7 @@ type ICacheLike<T> = { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -34,0 +39,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -32,2 +32,7 @@ type ICacheLike<T> = { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -34,0 +39,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -32,2 +32,7 @@ type ICacheLike<T> = { | ||
| withCredentials?: boolean; | ||
| /** | ||
| * some API is get data, but the method is not 'GET', | ||
| * add `isGet: true`, can let the plugins know this is also a `GET` API | ||
| */ | ||
| isGet?: boolean; | ||
| } | ||
@@ -34,0 +39,0 @@ type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & { |
@@ -1,1 +0,1 @@ | ||
| import{lru as t}from"tiny-lru";function e(t,e,n,r,i,o,u){try{var l=t[o](u),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,o){var u=t.apply(n,r);function l(t){e(u,i,o,l,a,"next",t)}function a(t){e(u,i,o,l,a,"throw",t)}l(void 0)})}}function r(e={}){let{enableThrottle:r,threshold:i=1e3,throttleCache:o=t(10)}=e;return function(t){let e=(e,r)=>{let i=n(function*(){try{let n=yield t(r);return o.set(e,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(t){throw"delete"in o?o.delete(e):o.del(e),t}})();return o.set(e,{timestamp:Date.now(),value:i}),i};return n(function*(n){let{_url:u,encode:l,threshold:a=i,enableThrottle:f=r,data:s}=n,c="GET"===n.method,m=typeof f;if("undefined"===m?c:"function"===m?f(n):!!f){let t=function(t,e,n){let r=e?n(e):"";r&&(r=t.includes("?")?t+"&"+r:t+"?"+r);let[i,o]=r.split("?");if(o){let t=o.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(u,s,l),r=Date.now(),i=o.get(t)||{timestamp:r};if(r-i.timestamp<=a){let t=i.value;if(t)return t}return e(t,n)}return t(n)})}}export{r as default}; | ||
| import{lru as t}from"tiny-lru";function e(t,e,n,r,i,o,u){try{var l=t[o](u),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,o){var u=t.apply(n,r);function l(t){e(u,i,o,l,a,"next",t)}function a(t){e(u,i,o,l,a,"throw",t)}l(void 0)})}}function r(e={}){let{enableThrottle:r,threshold:i=1e3,throttleCache:o=t(10)}=e;return function(t){let e=(e,r)=>{let i=n(function*(){try{let n=yield t(r);return o.set(e,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(t){throw"delete"in o?o.delete(e):o.del(e),t}})();return o.set(e,{timestamp:Date.now(),value:i}),i};return n(function*(n){let{_url:u,encode:l,threshold:a=i,enableThrottle:f=r,data:s}=n,c="GET"===n.method||n.isGet,m=typeof f;if("undefined"===m?c:"function"===m?f(n):!!f){let t=function(t,e,n){let r=e?n(e):"";r&&(r=t.includes("?")?t+"&"+r:t+"?"+r);let[i,o]=r.split("?");if(o){let t=o.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(u,s,l),r=Date.now(),i=o.get(t)||{timestamp:r};if(r-i.timestamp<=a){let t=i.value;if(t)return t}return e(t,n)}return t(n)})}}export{r as default}; |
@@ -1,1 +0,1 @@ | ||
| import{lru as t}from"tiny-lru";function e(t,e,n,r,i,o,u){try{var l=t[o](u),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,o){var u=t.apply(n,r);function l(t){e(u,i,o,l,a,"next",t)}function a(t){e(u,i,o,l,a,"throw",t)}l(void 0)})}}function r(e={}){let{enableThrottle:r,threshold:i=1e3,throttleCache:o=t(10)}=e;return function(t){let e=(e,r)=>{let i=n(function*(){try{let n=yield t(r);return o.set(e,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(t){throw"delete"in o?o.delete(e):o.del(e),t}})();return o.set(e,{timestamp:Date.now(),value:i}),i};return n(function*(n){let{_url:u,encode:l,threshold:a=i,enableThrottle:f=r,data:s}=n,c="GET"===n.method,m=typeof f;if("undefined"===m?c:"function"===m?f(n):!!f){let t=function(t,e,n){let r=e?n(e):"";r&&(r=t.includes("?")?t+"&"+r:t+"?"+r);let[i,o]=r.split("?");if(o){let t=o.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(u,s,l),r=Date.now(),i=o.get(t)||{timestamp:r};if(r-i.timestamp<=a){let t=i.value;if(t)return t}return e(t,n)}return t(n)})}}export{r as default}; | ||
| import{lru as t}from"tiny-lru";function e(t,e,n,r,i,o,u){try{var l=t[o](u),a=l.value}catch(t){n(t);return}l.done?e(a):Promise.resolve(a).then(r,i)}function n(t){return function(){var n=this,r=arguments;return new Promise(function(i,o){var u=t.apply(n,r);function l(t){e(u,i,o,l,a,"next",t)}function a(t){e(u,i,o,l,a,"throw",t)}l(void 0)})}}function r(e={}){let{enableThrottle:r,threshold:i=1e3,throttleCache:o=t(10)}=e;return function(t){let e=(e,r)=>{let i=n(function*(){try{let n=yield t(r);return o.set(e,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(t){throw"delete"in o?o.delete(e):o.del(e),t}})();return o.set(e,{timestamp:Date.now(),value:i}),i};return n(function*(n){let{_url:u,encode:l,threshold:a=i,enableThrottle:f=r,data:s}=n,c="GET"===n.method||n.isGet,m=typeof f;if("undefined"===m?c:"function"===m?f(n):!!f){let t=function(t,e,n){let r=e?n(e):"";r&&(r=t.includes("?")?t+"&"+r:t+"?"+r);let[i,o]=r.split("?");if(o){let t=o.split("&");return`${i}?${t.sort().join("&")}`}return r||t}(u,s,l),r=Date.now(),i=o.get(t)||{timestamp:r};if(r-i.timestamp<=a){let t=i.value;if(t)return t}return e(t,n)}return t(n)})}}export{r as default}; |
+27
-14
@@ -317,7 +317,7 @@ [](https://github.com/suhaotian/xior/actions/workflows/check.yml) | ||
| | Param | Type | Default value | Description | | ||
| | ------------- | ---------------------------------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------- | | ||
| | retryTimes | number | 2 | Set the retry times for failed request | | ||
| | retryInterval | number | 3000 | After first time retry, the next retries interval time, default interval is 3 seconds | | ||
| | enableRetry | boolean \| ((config: Xiorconfig, error: XiorRequestConfig) => boolean) | (config, error) => config.method === 'GET' | Default only retry if `GET` request error and `retryTimes > 0` | | ||
| | Param | Type | Default value | Description | | ||
| | ------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------- | | ||
| | retryTimes | number | 2 | Set the retry times for failed request | | ||
| | retryInterval | number | 3000 | After first time retry, the next retries interval time, default interval is 3 seconds | | ||
| | enableRetry | boolean \| ((config: Xiorconfig, error: XiorRequestConfig) => boolean) | (config, error) => config.method === 'GET' \|\| config.isGet | Default only retry if `GET` request error and `retryTimes > 0` | | ||
@@ -373,7 +373,7 @@ Basic usage: | ||
| | Param | Type | Default value | Description | | ||
| | -------------- | -------------------------------------------- | ----------------------------------- | ------------------------------------------------------------------------------------------ | | ||
| | threshold | number | 1000 | The number of milliseconds to throttle request invocations to | | ||
| | enableThrottle | boolean \| ((config: Xiorconfig) => boolean) | (config) => config.method === 'GET' | Default only enabled in `GET` request | | ||
| | throttleCache | CacheLike | lru(10) | CacheLike instance that will be used for storing throttled requests, use `tiny-lru` module | | ||
| | Param | Type | Default value | Description | | ||
| | -------------- | -------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------ | | ||
| | threshold | number | 1000 | The number of milliseconds to throttle request invocations to | | ||
| | enableThrottle | boolean \| ((config: Xiorconfig) => boolean) | (config) => config.method === 'GET' \|\| config.isGet | Default only enabled in `GET` request | | ||
| | throttleCache | CacheLike | lru(10) | CacheLike instance that will be used for storing throttled requests, use `tiny-lru` module | | ||
@@ -406,2 +406,14 @@ Basic usage: | ||
| }); // response from cache | ||
| // make post method as get method use `{isGet: true}`, | ||
| // useful when some API is get data but the method is `post` | ||
| http.post('/get', null, { | ||
| isGet: true, | ||
| }); // make real http request | ||
| http.post('/get', null, { | ||
| isGet: true, | ||
| }); // response from cache | ||
| http.post('/get', null, { | ||
| isGet: true, | ||
| }); // response from cache | ||
| ``` | ||
@@ -426,6 +438,6 @@ | ||
| | Param | Type | Default value | Description | | ||
| | ------------ | -------------------------------------------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | ||
| | enableCache | boolean \| ((config: Xiorconfig) => boolean) | (config) => config.method === 'GET' | Default only enabled in `GET` request | | ||
| | defaultCache | CacheLike | lru(100, 1000\*60\*5) | will used for storing requests by default, except you define a custom Cache with your request config, use `tiny-lru` module | | ||
| | Param | Type | Default value | Description | | ||
| | ------------ | -------------------------------------------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | | ||
| | enableCache | boolean \| ((config: Xiorconfig) => boolean) | (config) => config.method === 'GET' \|\| config.isGet | Default only enabled in `GET` request | | ||
| | defaultCache | CacheLike | lru(100, 1000\*60\*5) | will used for storing requests by default, except you define a custom Cache with your request config, use `tiny-lru` module | | ||
@@ -1189,2 +1201,3 @@ Basic usage: | ||
| - [axios-extensions](https://github.com/kuitos/axios-extensions) | ||
| - [axios-mock-adapter](https://github.com/ctimmerm/axios-mock-adapter) | ||
| - [ts-deepmerge](https://github.com/voodoocreation/ts-deepmerge) | ||
@@ -1191,0 +1204,0 @@ - [tiny-lru](https://github.com/avoidwork/tiny-lru) |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
134622
3.18%1027
5.12%1202
1.09%