Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xior

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xior - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

8

dist/index.esm.d.ts

@@ -43,3 +43,3 @@ export { merge } from 'ts-deepmerge';

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -189,4 +189,6 @@ /** Code Ref: https://github.com/jacobheun/any-signal/pull/40/files */

fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
createGet<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
createPost<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {

@@ -193,0 +195,0 @@ /** @deprecated No `data` in `GET` method */

@@ -1,1 +0,1 @@

import{merge as e}from"ts-deepmerge";export{merge}from"ts-deepmerge";function t(e,t){let r=new globalThis.AbortController;function n(e){r.abort(e),i()}let o=[];for(let t of e){if((null==t?void 0:t.aborted)===!0){n(t.reason);break}if((null==t?void 0:t.addEventListener)!=null){let e=()=>{n(t.reason)};o.push(()=>{(null==t?void 0:t.removeEventListener)!=null&&t.removeEventListener("abort",e)}),t.addEventListener("abort",e)}}function i(){o.forEach(e=>{e()}),null==t||t()}let s=r.signal;return s.clear=i,s}function r(e,t,r){let n=t?r(t):"";n&&(n=e+(e.includes("?")?"&"+n:"?"+n));let[o,i]=n.split("?");if(i){let e=i.split("&");return`${o}?${e.sort().join("&")}`}return n||e}function n(e){return new Promise(t=>{setTimeout(()=>{t("ok")},e)})}function o(e,t=!0,r=null){if(null==e)return"";let n=[],i=t?encodeURIComponent:e=>e;for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let a=e[s],u=r?`${r}[${i(s)}]`:i(s);if("object"==typeof a){let e=o(a,t,u);""!==e&&n.push(e)}else Array.isArray(a)?a.forEach((e,t)=>{let r=`${u}[${t}]`;n.push(`${i(r)}=${i(e)}`)}):n.push(`${i(u)}=${i(a)}`)}return n.join("&")}function i(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function s(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}class a extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}class u extends a{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}}function l(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}function c(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let f="application/",d=`${f}x-www-form-urlencoded`,p=`${f}json`;function m(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}function E(){var t;return t=function*(t){let r=t.paramsSerializer||o,n=!1!==t.encodeURI,i=t.method?t.method.toUpperCase():"GET",s=t.url||"",a=s,u=t.data,l=u,c=(null==t?void 0:t.headers)||{},f=t.params||{};if(u&&!(u instanceof FormData)){let n="";if(null==t?void 0:t.headers){let e=Object.keys(t.headers).find(e=>"content-type"===e.toLowerCase());e&&(n=t.headers[e],t.headers["Content-Type"]=n,"Content-Type"!==e&&delete t.headers[e])}let o=m(i);n||(n=o?d:p,c["Content-Type"]=n),o&&t.params&&(f=e({},u||{},f)),n===p?l=JSON.stringify(u):!o&&n===d&&u&&"object"==typeof u&&(l=r(u))}return Object.keys(f).length>0&&(s+=s.includes("?")?`&${r(f,n)}`:`?${r(f,n)}`),h({},t,{data:u,_data:l,url:a,_url:s,method:i,headers:c,paramsSerializer:r})},(E=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function s(e){c(i,n,o,s,a,"next",e)}function a(e){c(i,n,o,s,a,"throw",e)}s(void 0)})}).apply(this,arguments)}function y(e,t,r,n,o,i,s){try{var a=e[i](s),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,o)}function v(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function s(e){y(i,n,o,s,a,"next",e)}function a(e){y(i,n,o,s,a,"throw",e)}s(void 0)})}}function g(){return(g=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let b="undefined"!=typeof AbortController;class O{static create(e){return new O(e)}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter(t=>t!==e)},clear:()=>{this.REQI=[]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter(t=>t.fn!==e)},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this.P.push(e),e),eject:e=>{this.P=this.P.filter(t=>t!==e)},clear:()=>{this.P=[]}}}request(t){var r=this;return v(function*(){let n=e({},r.config||{},r.defaults||{},"string"==typeof t?{url:t}:t||{},{headers:{},params:{}});for(let e of(n.paramsSerializer||(n.paramsSerializer=o),r.REQI))n=yield e(n);let i=r.fetch.bind(r);return r.P.forEach(e=>{i=e(i)}),i(n)})()}fetch(e){var r=this;return v(function*(){var n,o;let l,c;let h=yield function(e){return E.apply(this,arguments)}(e),{url:f,method:d,headers:p,timeout:y,signal:v,data:O,_data:P,_url:R}=h,T=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}(h,["url","method","headers","timeout","signal","data","_data","_url"]);e._url=R;let j=[];if(y&&b){let t=new AbortController;c=setTimeout(()=>{t.abort(new u(`timeout of ${y}ms exceeded`,e))},y),j.push(t.signal)}v&&j.push(v),l=j[0],j.length>1&&(l=t(j,()=>{clearTimeout(c)}));let S=R||f||"";e.baseURL&&!i(S)&&(S=s(e.baseURL,S));let w=yield fetch(S,g({body:m(d)?void 0:P},T,{signal:l,method:d,headers:p}));c&&clearTimeout(c),null==l||null==(n=l.clear)||n.call(l);let I={response:w,config:e,status:w.status,statusText:w.statusText,headers:w.headers};if(!w.ok){let t;try{(t=yield w.text())&&(t=JSON.parse(t))}catch(e){}let n=new a(w.status?`Request failed with status code ${w.status}`:"Network error",e,g({data:t},I));for(let e of r.RESI)if(e.onRejected){let t=yield e.onRejected(n);if(null==t?void 0:null==(o=t.response)?void 0:o.ok)return t}throw n}if("HEAD"===d)return g({data:void 0,request:e},I);let{responseType:x}=e;if(!x||["json","text"].includes(x)){let t;try{(t=yield w.text())&&"text"!==x&&(t=JSON.parse(t))}catch(e){}let n={data:t,config:e,request:e,response:w};for(let e of r.RESI)n=yield e.fn(n);return g({data:n.data,request:e},I)}return g({data:void 0,request:e},I)})()}createGet(e){return(t,r)=>this.request(r?g({},r,{method:e,url:t}):{method:e,url:t})}createPost(e){return(t,r,n)=>this.request(n?g({},n,{method:e,url:t,data:r}):{method:e,url:t,data:r})}get(e,t){return this.createGet("GET")(e,t)}head(e,t){return this.createGet("HEAD")(e,t)}post(e,t,r){return this.createPost("POST")(e,t,r)}put(e,t,r){return this.createPost("PUT")(e,t,r)}patch(e,t,r){return this.createPost("PATCH")(e,t,r)}delete(e,t){return this.createGet("DELETE")(e,t)}options(e,t){return this.createGet("OPTIONS")(e,t)}constructor(e){this.REQI=[],this.RESI=[],this.P=[],this.config=e,this.defaults={params:{},headers:{}}}}O.VERSION="0.3.0";let P=Object.assign(O.create(),{create:O.create,VERSION:O.VERSION});export{a as XiorError,u as XiorTimeoutError,t as anySignal,r as buildSortedURL,P as default,n as delay,o as encodeParams,i as isAbsoluteURL,l as isXiorError,s as joinPath,O as xior};
import{merge as e}from"ts-deepmerge";export{merge}from"ts-deepmerge";function t(e,t){let r=new globalThis.AbortController;function n(e){r.abort(e),o()}let i=[];for(let t of e){if((null==t?void 0:t.aborted)===!0){n(t.reason);break}if((null==t?void 0:t.addEventListener)!=null){let e=()=>{n(t.reason)};i.push(()=>{(null==t?void 0:t.removeEventListener)!=null&&t.removeEventListener("abort",e)}),t.addEventListener("abort",e)}}function o(){i.forEach(e=>{e()}),null==t||t()}let s=r.signal;return s.clear=o,s}function r(e,t,r){let n=t?r(t):"";n&&(n=e+(e.includes("?")?"&"+n:"?"+n));let[i,o]=n.split("?");if(o){let e=o.split("&");return`${i}?${e.sort().join("&")}`}return n||e}function n(e){return new Promise(t=>{setTimeout(()=>{t("ok")},e)})}function i(e,t=!0,r=null){if(null==e)return"";let n=[],o=t?encodeURIComponent:e=>e;for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let a=e[s],u=r?`${r}[${o(s)}]`:o(s);if("object"==typeof a){let e=i(a,t,u);""!==e&&n.push(e)}else Array.isArray(a)?a.forEach((e,t)=>{let r=`${u}[${t}]`;n.push(`${o(r)}=${o(e)}`)}):n.push(`${o(u)}=${o(a)}`)}return n.join("&")}function o(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function s(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}class a extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}class u extends a{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}}function l(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}function c(e,t,r,n,i,o,s){try{var a=e[o](s),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,i)}function h(){return(h=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let f="application/",d=`${f}x-www-form-urlencoded`,p=`${f}json`;function m(){var t;return t=function*(t){let r=t.paramsSerializer||i,n=!1!==t.encodeURI,o=t.method?t.method.toUpperCase():"GET",s=t.url||"",a=s,u=t.data,l=u,c=(null==t?void 0:t.headers)||{},f=t.params||{},m=function(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}(o);if(u&&!(u instanceof FormData)){let n="";if(null==t?void 0:t.headers){let e=Object.keys(t.headers).find(e=>"content-type"===e.toLowerCase());e&&(n=t.headers[e],t.headers["Content-Type"]=n,"Content-Type"!==e&&delete t.headers[e])}n||(n=m?d:p,c["Content-Type"]=n),m&&t.params&&(f=e({},u||{},f)),n===p?l=JSON.stringify(u):!m&&n===d&&u&&"object"==typeof u&&(l=r(u))}return Object.keys(f).length>0&&(s+=s.includes("?")?`&${r(f,n)}`:`?${r(f,n)}`),h({},t,{data:u,_data:l,url:a,_url:s,method:o,headers:c,isGet:m})},(m=function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function s(e){c(o,n,i,s,a,"next",e)}function a(e){c(o,n,i,s,a,"throw",e)}s(void 0)})}).apply(this,arguments)}function E(e,t,r,n,i,o,s){try{var a=e[o](s),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,i)}function y(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function s(e){E(o,n,i,s,a,"next",e)}function a(e){E(o,n,i,s,a,"throw",e)}s(void 0)})}}function v(){return(v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}let g="undefined"!=typeof AbortController;class b{static create(e){return new b(e)}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter(t=>t!==e)},clear:()=>{this.REQI=[]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter(t=>t.fn!==e)},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this.P.push(e),e),eject:e=>{this.P=this.P.filter(t=>t!==e)},clear:()=>{this.P=[]}}}request(t){var r=this;return y(function*(){let n=e({},r.config||{},r.defaults||{},"string"==typeof t?{url:t}:t||{},{headers:{},params:{}});for(let e of(n.paramsSerializer||(n.paramsSerializer=i),r.REQI))n=yield e(n);let o=r.fetch.bind(r);return r.P.forEach(e=>{o=e(o,r)}),o(n)})()}fetch(e){var r=this;return y(function*(){var n,i;let l,c;let h=yield function(e){return m.apply(this,arguments)}(e),{url:f,method:d,headers:p,timeout:E,signal:y,data:b,_data:O,_url:P,isGet:R}=h,T=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}(h,["url","method","headers","timeout","signal","data","_data","_url","isGet"]);e._url=P;let j=[];if(E&&g){let t=new AbortController;c=setTimeout(()=>{t.abort(new u(`timeout of ${E}ms exceeded`,e))},E),j.push(t.signal)}y&&j.push(y),l=j[0],j.length>1&&(l=t(j,()=>{clearTimeout(c)}));let S=P||f||"";e.baseURL&&!o(S)&&(S=s(e.baseURL,S));let w=yield fetch(S,v({body:R?void 0:O},T,{signal:l,method:d,headers:p}));c&&clearTimeout(c),null==l||null==(n=l.clear)||n.call(l);let I={response:w,config:e,status:w.status,statusText:w.statusText,headers:w.headers};if(!w.ok){let t;try{(t=yield w.text())&&(t=JSON.parse(t))}catch(e){}let n=new a(w.status?`Request failed with status code ${w.status}`:"Network error",e,v({data:t},I));for(let e of r.RESI)if(e.onRejected){let t=yield e.onRejected(n);if(null==t?void 0:null==(i=t.response)?void 0:i.ok)return t}throw n}if("HEAD"===d)return v({data:void 0,request:e},I);let{responseType:x}=e;if(!x||["json","text"].includes(x)){let t;try{(t=yield w.text())&&"text"!==x&&(t=JSON.parse(t))}catch(e){}let n={data:t,config:e,request:e,response:w};for(let e of r.RESI)n=yield e.fn(n);return v({data:n.data,request:e},I)}return v({data:void 0,request:e},I)})()}cG(e){return(t,r)=>this.request(r?v({},r,{method:e,url:t}):{method:e,url:t})}cP(e){return(t,r,n)=>this.request(n?v({},n,{method:e,url:t,data:r}):{method:e,url:t,data:r})}get(e,t){return this.cG("GET")(e,t)}head(e,t){return this.cG("HEAD")(e,t)}post(e,t,r){return this.cP("POST")(e,t,r)}put(e,t,r){return this.cP("PUT")(e,t,r)}patch(e,t,r){return this.cP("PATCH")(e,t,r)}delete(e,t){return this.cG("DELETE")(e,t)}options(e,t){return this.cG("OPTIONS")(e,t)}constructor(e){this.REQI=[],this.RESI=[],this.P=[],this.config=e,this.defaults={params:{},headers:{}}}}b.VERSION="0.3.1";let O=Object.assign(b.create(),{create:b.create,VERSION:b.VERSION});export{a as XiorError,u as XiorTimeoutError,t as anySignal,r as buildSortedURL,O as default,n as delay,i as encodeParams,o as isAbsoluteURL,l as isXiorError,s as joinPath,b as xior};

@@ -43,3 +43,3 @@ export { merge } from 'ts-deepmerge';

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -189,4 +189,6 @@ /** Code Ref: https://github.com/jacobheun/any-signal/pull/40/files */

fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
createGet<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
createPost<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {

@@ -193,0 +195,0 @@ /** @deprecated No `data` in `GET` method */

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xior=t():e.xior=t()}(this,(()=>(()=>{"use strict";var e={699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=void 0,t.anySignal=function(e,t){const r=new globalThis.AbortController;function o(e){r.abort(e),i()}const n=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){const e=()=>{o(t.reason)};n.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==t||t()}const s=r.signal;return s.clear=i,s}},509:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});const i=r(895);n(r(895),t),n(r(340),t),n(r(976),t);const s=Object.assign(i.xior.create(),{create:i.xior.create,VERSION:i.xior.VERSION});t.default=s},393:function(e,t,r){var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.likeGET=void 0;const n=r(976),i="application/",s=`${i}x-www-form-urlencoded`,a=`${i}json`;function c(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}t.likeGET=c,t.default=function(e){return o(this,void 0,void 0,(function*(){const t=e.paramsSerializer||n.encodeParams,r=!1!==e.encodeURI,o=e.method?e.method.toUpperCase():"GET";let i=e.url||"";const u=i,l=e.data;let d=l;const f=(null==e?void 0:e.headers)||{};let h=e.params||{};if(l&&!(l instanceof FormData)){let r="";if(null==e?void 0:e.headers){const t=Object.keys(e.headers).find((e=>"content-type"===e.toLowerCase()));t&&(r=e.headers[t],e.headers["Content-Type"]=r,"Content-Type"!==t&&delete e.headers[t])}const i=c(o);r||(r=i?s:a,f["Content-Type"]=r),i&&e.params&&(h=(0,n.merge)({},l||{},h)),r===a?d=JSON.stringify(l):!i&&r===s&&l&&"object"==typeof l&&(d=t(l))}return Object.keys(h).length>0&&(i+=i.includes("?")?`&${t(h,r)}`:`?${t(h,r)}`),Object.assign(Object.assign({},e),{data:l,_data:d,url:u,_url:i,method:o,headers:f,paramsSerializer:t})}))}},729:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const o=r(602);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}})},629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));const[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e}},99:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const n=o(r(629));t.buildSortedURL=n.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}},340:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},976:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.isXiorError=t.XiorTimeoutError=t.XiorError=t.joinPath=t.isAbsoluteURL=t.encodeParams=void 0,n(r(699),t),n(r(729),t),n(r(99),t),t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";const n=[],i=r?encodeURIComponent:e=>e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const a=t[s],c=o?`${o}[${i(s)}]`:i(s);if("object"==typeof a){const t=e(a,r,c);""!==t&&n.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{const r=`${c}[${t}]`;n.push(`${i(r)}=${i(e)}`)})):n.push(`${i(c)}=${i(a)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e};class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}t.XiorError=i,t.XiorTimeoutError=class extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}},895:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&o(t,e,r);return n(t,e),t},s=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))},a=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.xior=void 0;const c=i(r(393)),u=r(976),l="undefined"!=typeof AbortController;class d{static create(e){return new d(e)}constructor(e){this.REQI=[],this.RESI=[],this.P=[],this.config=e,this.defaults={params:{},headers:{}}}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter((t=>t!==e))},clear:()=>{this.REQI=[]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter((t=>t.fn!==e))},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this.P.push(e),e),eject:e=>{this.P=this.P.filter((t=>t!==e))},clear:()=>{this.P=[]}}}request(e){return s(this,void 0,void 0,(function*(){let t=(0,u.merge)({},this.config||{},this.defaults||{},"string"==typeof e?{url:e}:e||{},{headers:{},params:{}});t.paramsSerializer||(t.paramsSerializer=u.encodeParams);for(const e of this.REQI)t=yield e(t);let r=this.fetch.bind(this);return this.P.forEach((e=>{r=e(r)})),r(t)}))}fetch(e){var t,r;return s(this,void 0,void 0,(function*(){const o=yield(0,c.default)(e),{url:n,method:i,headers:s,timeout:d,signal:f,data:h,_data:p,_url:b}=o,y=a(o,["url","method","headers","timeout","signal","data","_data","_url"]);let m;e._url=b;const O=[];let g;if(d&&l){const t=new AbortController;g=setTimeout((()=>{t.abort(new u.XiorTimeoutError(`timeout of ${d}ms exceeded`,e))}),d),O.push(t.signal)}f&&O.push(f),m=O[0],O.length>1&&(m=(0,u.anySignal)(O,(()=>{clearTimeout(g)})));let v=b||n||"";e.baseURL&&!(0,u.isAbsoluteURL)(v)&&(v=(0,u.joinPath)(e.baseURL,v));const j=yield fetch(v,Object.assign(Object.assign({body:(0,c.likeGET)(i)?void 0:p},y),{signal:m,method:i,headers:s}));g&&clearTimeout(g),null===(t=null==m?void 0:m.clear)||void 0===t||t.call(m);const _={response:j,config:e,status:j.status,statusText:j.statusText,headers:j.headers};if(!j.ok){let t;try{t=yield j.text(),t&&(t=JSON.parse(t))}catch(e){}const o=new u.XiorError(j.status?`Request failed with status code ${j.status}`:"Network error",e,Object.assign({data:t},_));for(const e of this.RESI)if(e.onRejected){const t=yield e.onRejected(o);if(null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.ok)return t}throw o}if("HEAD"===i)return Object.assign({data:void 0,request:e},_);const{responseType:E}=e;if(!E||["json","text"].includes(E)){let t;try{t=yield j.text(),t&&"text"!==E&&(t=JSON.parse(t))}catch(e){}let r={data:t,config:e,request:e,response:j};for(const e of this.RESI)r=yield e.fn(r);return Object.assign({data:r.data,request:e},_)}return Object.assign({data:void 0,request:e},_)}))}createGet(e){return(t,r)=>this.request(r?Object.assign(Object.assign({},r),{method:e,url:t}):{method:e,url:t})}createPost(e){return(t,r,o)=>this.request(o?Object.assign(Object.assign({},o),{method:e,url:t,data:r}):{method:e,url:t,data:r})}get(e,t){return this.createGet("GET")(e,t)}head(e,t){return this.createGet("HEAD")(e,t)}post(e,t,r){return this.createPost("POST")(e,t,r)}put(e,t,r){return this.createPost("PUT")(e,t,r)}patch(e,t,r){return this.createPost("PATCH")(e,t,r)}delete(e,t){return this.createGet("DELETE")(e,t)}options(e,t){return this.createGet("OPTIONS")(e,t)}}t.xior=d,d.VERSION="0.3.0"},602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const r=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1};t.merge=(...e)=>e.reduce(((e,o)=>{if(Array.isArray(o))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(o).forEach((n=>{["__proto__","constructor","prototype"].includes(n)||(Array.isArray(e[n])&&Array.isArray(o[n])?e[n]=t.merge.options.mergeArrays?t.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:r(e[n])&&r(o[n])?e[n]=(0,t.merge)(e[n],o[n]):e[n]=void 0===o[n]?t.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};t.merge.options=o,t.merge.withOptions=(e,...r)=>{t.merge.options=Object.assign(Object.assign({},o),e);const n=(0,t.merge)(...r);return t.merge.options=o,n}}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(509);return r.default})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xior=t():e.xior=t()}(this,(()=>(()=>{"use strict";var e={699:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=void 0,t.anySignal=function(e,t){const r=new globalThis.AbortController;function o(e){r.abort(e),i()}const n=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){const e=()=>{o(t.reason)};n.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==t||t()}const s=r.signal;return s.clear=i,s}},509:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});const i=r(895);n(r(895),t),n(r(340),t),n(r(976),t);const s=Object.assign(i.xior.create(),{create:i.xior.create,VERSION:i.xior.VERSION});t.default=s},393:function(e,t,r){var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.likeGET=void 0;const n=r(976),i="application/",s=`${i}x-www-form-urlencoded`,a=`${i}json`;function c(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}t.likeGET=c,t.default=function(e){return o(this,void 0,void 0,(function*(){const t=e.paramsSerializer||n.encodeParams,r=!1!==e.encodeURI,o=e.method?e.method.toUpperCase():"GET";let i=e.url||"";const u=i,l=e.data;let d=l;const f=(null==e?void 0:e.headers)||{};let h=e.params||{};const p=c(o);if(l&&!(l instanceof FormData)){let r="";if(null==e?void 0:e.headers){const t=Object.keys(e.headers).find((e=>"content-type"===e.toLowerCase()));t&&(r=e.headers[t],e.headers["Content-Type"]=r,"Content-Type"!==t&&delete e.headers[t])}r||(r=p?s:a,f["Content-Type"]=r),p&&e.params&&(h=(0,n.merge)({},l||{},h)),r===a?d=JSON.stringify(l):!p&&r===s&&l&&"object"==typeof l&&(d=t(l))}return Object.keys(h).length>0&&(i+=i.includes("?")?`&${t(h,r)}`:`?${t(h,r)}`),Object.assign(Object.assign({},e),{data:l,_data:d,url:u,_url:i,method:o,headers:f,isGet:p})}))}},729:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const o=r(602);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}})},629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));const[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e}},99:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const n=o(r(629));t.buildSortedURL=n.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}},340:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},976:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.isXiorError=t.XiorTimeoutError=t.XiorError=t.joinPath=t.isAbsoluteURL=t.encodeParams=void 0,n(r(699),t),n(r(729),t),n(r(99),t),t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";const n=[],i=r?encodeURIComponent:e=>e;for(const s in t)if(Object.prototype.hasOwnProperty.call(t,s)){const a=t[s],c=o?`${o}[${i(s)}]`:i(s);if("object"==typeof a){const t=e(a,r,c);""!==t&&n.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{const r=`${c}[${t}]`;n.push(`${i(r)}=${i(e)}`)})):n.push(`${i(c)}=${i(a)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e};class i extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}t.XiorError=i,t.XiorTimeoutError=class extends i{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name}},895:function(e,t,r){var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))},n=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.xior=void 0;const s=i(r(393)),a=r(976),c="undefined"!=typeof AbortController;class u{static create(e){return new u(e)}constructor(e){this.REQI=[],this.RESI=[],this.P=[],this.config=e,this.defaults={params:{},headers:{}}}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter((t=>t!==e))},clear:()=>{this.REQI=[]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter((t=>t.fn!==e))},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this.P.push(e),e),eject:e=>{this.P=this.P.filter((t=>t!==e))},clear:()=>{this.P=[]}}}request(e){return o(this,void 0,void 0,(function*(){let t=(0,a.merge)({},this.config||{},this.defaults||{},"string"==typeof e?{url:e}:e||{},{headers:{},params:{}});t.paramsSerializer||(t.paramsSerializer=a.encodeParams);for(const e of this.REQI)t=yield e(t);let r=this.fetch.bind(this);return this.P.forEach((e=>{r=e(r,this)})),r(t)}))}fetch(e){var t,r;return o(this,void 0,void 0,(function*(){const o=yield(0,s.default)(e),{url:i,method:u,headers:l,timeout:d,signal:f,data:h,_data:p,_url:y,isGet:b}=o,m=n(o,["url","method","headers","timeout","signal","data","_data","_url","isGet"]);let g;e._url=y;const v=[];let O;if(d&&c){const t=new AbortController;O=setTimeout((()=>{t.abort(new a.XiorTimeoutError(`timeout of ${d}ms exceeded`,e))}),d),v.push(t.signal)}f&&v.push(f),g=v[0],v.length>1&&(g=(0,a.anySignal)(v,(()=>{clearTimeout(O)})));let j=y||i||"";e.baseURL&&!(0,a.isAbsoluteURL)(j)&&(j=(0,a.joinPath)(e.baseURL,j));const _=yield fetch(j,Object.assign(Object.assign({body:b?void 0:p},m),{signal:g,method:u,headers:l}));O&&clearTimeout(O),null===(t=null==g?void 0:g.clear)||void 0===t||t.call(g);const E={response:_,config:e,status:_.status,statusText:_.statusText,headers:_.headers};if(!_.ok){let t;try{t=yield _.text(),t&&(t=JSON.parse(t))}catch(e){}const o=new a.XiorError(_.status?`Request failed with status code ${_.status}`:"Network error",e,Object.assign({data:t},E));for(const e of this.RESI)if(e.onRejected){const t=yield e.onRejected(o);if(null===(r=null==t?void 0:t.response)||void 0===r?void 0:r.ok)return t}throw o}if("HEAD"===u)return Object.assign({data:void 0,request:e},E);const{responseType:P}=e;if(!P||["json","text"].includes(P)){let t;try{t=yield _.text(),t&&"text"!==P&&(t=JSON.parse(t))}catch(e){}let r={data:t,config:e,request:e,response:_};for(const e of this.RESI)r=yield e.fn(r);return Object.assign({data:r.data,request:e},E)}return Object.assign({data:void 0,request:e},E)}))}cG(e){return(t,r)=>this.request(r?Object.assign(Object.assign({},r),{method:e,url:t}):{method:e,url:t})}cP(e){return(t,r,o)=>this.request(o?Object.assign(Object.assign({},o),{method:e,url:t,data:r}):{method:e,url:t,data:r})}get(e,t){return this.cG("GET")(e,t)}head(e,t){return this.cG("HEAD")(e,t)}post(e,t,r){return this.cP("POST")(e,t,r)}put(e,t,r){return this.cP("PUT")(e,t,r)}patch(e,t,r){return this.cP("PATCH")(e,t,r)}delete(e,t){return this.cG("DELETE")(e,t)}options(e,t){return this.cG("OPTIONS")(e,t)}}t.xior=u,u.VERSION="0.3.1"},602:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const r=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}return"[object Object]"===Object.prototype.toString.call(e)}return!1};t.merge=(...e)=>e.reduce(((e,o)=>{if(Array.isArray(o))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(o).forEach((n=>{["__proto__","constructor","prototype"].includes(n)||(Array.isArray(e[n])&&Array.isArray(o[n])?e[n]=t.merge.options.mergeArrays?t.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:r(e[n])&&r(o[n])?e[n]=(0,t.merge)(e[n],o[n]):e[n]=void 0===o[n]?t.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};t.merge.options=o,t.merge.withOptions=(e,...r)=>{t.merge.options=Object.assign(Object.assign({},o),e);const n=(0,t.merge)(...r);return t.merge.options=o,n}}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(509);return r.default})()));

@@ -64,3 +64,3 @@ [Go back](./README.md)

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.1/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/plugins/mock.umd.js"></script>

@@ -83,3 +83,3 @@

```html
<script src="https://unpkg.com/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.1/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.2.6/plugins/mock.umd.js"></script>

@@ -86,0 +86,0 @@

{
"name": "xior",
"version": "0.3.0",
"version": "0.3.1",
"description": "A lite request lib based on fetch with plugins support, and axios similar API",

@@ -5,0 +5,0 @@ "repository": "suhaotian/xior",

@@ -10,2 +10,126 @@ type ICacheLike<T> = {

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -51,3 +175,3 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -54,0 +178,0 @@ type XiorPromise = Promise<XiorResponse>;

@@ -10,2 +10,126 @@ type ICacheLike<T> = {

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -51,3 +175,3 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -54,0 +178,0 @@ type XiorPromise = Promise<XiorResponse>;

@@ -0,1 +1,125 @@

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -41,3 +165,3 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -44,0 +168,0 @@ type XiorDedupeOptions = {

@@ -0,1 +1,125 @@

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -41,3 +165,3 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -44,0 +168,0 @@ type XiorDedupeOptions = {

@@ -10,2 +10,126 @@ type ICacheLike<T> = {

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -51,11 +175,4 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorErrorCacheOptions = {

@@ -62,0 +179,0 @@ /**

@@ -10,2 +10,126 @@ type ICacheLike<T> = {

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -51,11 +175,4 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorErrorCacheOptions = {

@@ -62,0 +179,0 @@ /**

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorErrorRetry=t():e.xiorErrorRetry=t()}(this,(()=>(()=>{"use strict";var e={629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){let r=t?n(t):"";r&&(r=e+(e.includes("?")?"&"+r:"?"+r));const[o,i]=r.split("?");return i?`${o}?${i.split("&").sort().join("&")}`:r||e}},351:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{f(r.next(e))}catch(e){i(e)}}function c(e){try{f(r.throw(e))}catch(e){i(e)}}function f(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}f((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const o=n(99);t.default=function(e={}){const{retryTimes:t,retryInterval:n,enableRetry:i,onRetry:u}=Object.assign({retryTimes:2,retryInterval:3e3},e||{});return function(e){return c=>r(this,void 0,void 0,(function*(){const{retryTimes:f=t,retryInterval:s=n,enableRetry:d=i,onRetry:l=u}=c;let a=!1,y=0;return function t(){return r(this,void 0,void 0,(function*(){try{return yield e(c)}catch(e){const n="GET"===c.method||c.isGet,r=typeof d,i="undefined"===r?n:"function"===r?d(c,e):Boolean(d);if(a=f===y,a||!i)throw e;const u="function"==typeof s?s(y):s;return u&&u>0&&y>0&&(yield(0,o.delay)(u)),y++,l&&l(c,e,y),t()}}))}()}))}}},99:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const o=r(n(629));t.buildSortedURL=o.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}}},t={},n=function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(351);return n.default})()));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorErrorRetry=t():e.xiorErrorRetry=t()}(this,(()=>(()=>{"use strict";var e={629:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){let r=t?n(t):"";r&&(r=e+(e.includes("?")?"&"+r:"?"+r));const[o,i]=r.split("?");return i?`${o}?${i.split("&").sort().join("&")}`:r||e}},351:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function u(e){try{f(r.next(e))}catch(e){i(e)}}function c(e){try{f(r.throw(e))}catch(e){i(e)}}function f(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(u,c)}f((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0});const o=n(99);t.default=function(e={}){const{retryTimes:t,retryInterval:n,enableRetry:i,onRetry:u}=Object.assign({retryTimes:2,retryInterval:3e3},e||{});return function(e,c){return f=>r(this,void 0,void 0,(function*(){const{retryTimes:s=t,retryInterval:l=n,enableRetry:d=i,onRetry:a=u}=f;let y=!1,p=0;return function t(n=!1){return r(this,void 0,void 0,(function*(){if(n&&(null==c?void 0:c.REQI))for(const e of c.REQI)f=yield e(f);try{return yield e(f)}catch(e){const n="GET"===f.method||f.isGet,r=typeof d,i="undefined"===r?n:"function"===r?d(f,e):Boolean(d);if(y=s===p,y||!i)throw e;const u="function"==typeof l?l(p):l;return u&&u>0&&p>0&&(yield(0,o.delay)(u)),p++,a&&a(f,e,p),t(!0)}}))}()}))}}},99:function(e,t,n){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.delay=t.buildSortedURL=void 0;const o=r(n(629));t.buildSortedURL=o.default,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))}}},t={},n=function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}(351);return n.default})()));

@@ -0,1 +1,125 @@

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -41,11 +165,4 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type ErrorRetryOptions = {

@@ -52,0 +169,0 @@ /** retry times, default: 2 */

@@ -0,1 +1,125 @@

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -41,11 +165,4 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type ErrorRetryOptions = {

@@ -52,0 +169,0 @@ /** retry times, default: 2 */

@@ -1,1 +0,1 @@

function t(t,r,n,e,o,i,u){try{var c=t[i](u),f=c.value}catch(t){n(t);return}c.done?r(f):Promise.resolve(f).then(e,o)}function r(r){return function(){var n=this,e=arguments;return new Promise(function(o,i){var u=r.apply(n,e);function c(r){t(u,o,i,c,f,"next",r)}function f(r){t(u,o,i,c,f,"throw",r)}c(void 0)})}}function n(){return(n=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t}).apply(this,arguments)}function e(t={}){let{retryTimes:e,retryInterval:o,enableRetry:i,onRetry:u}=n({},{retryTimes:2,retryInterval:3e3},t||{});return function(t){return r(function*(n){let{retryTimes:c=e,retryInterval:f=o,enableRetry:a=i,onRetry:l=u}=n,y=0;function s(){return p.apply(this,arguments)}function p(){return(p=r(function*(){try{return yield t(n)}catch(i){let t="GET"===n.method||n.isGet,r=typeof a,e="undefined"===r?t:"function"===r?a(n,i):!!a;if(c===y||!e)throw i;let o="function"==typeof f?f(y):f;return o&&o>0&&y>0&&(yield new Promise(t=>{setTimeout(()=>{t("ok")},o)})),y++,l&&l(n,i,y),s()}})).apply(this,arguments)}return s()})}}export{e as default};
function t(t,r,n,e,o,i,u){try{var f=t[i](u),l=f.value}catch(t){n(t);return}f.done?r(l):Promise.resolve(l).then(e,o)}function r(r){return function(){var n=this,e=arguments;return new Promise(function(o,i){var u=r.apply(n,e);function f(r){t(u,o,i,f,l,"next",r)}function l(r){t(u,o,i,f,l,"throw",r)}f(void 0)})}}function n(){return(n=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}return t}).apply(this,arguments)}function e(t={}){let{retryTimes:e,retryInterval:o,enableRetry:i,onRetry:u}=n({},{retryTimes:2,retryInterval:3e3},t||{});return function(t,n){return r(function*(f){let{retryTimes:l=e,retryInterval:c=o,enableRetry:a=i,onRetry:y=u}=f,s=0;function p(){return h.apply(this,arguments)}function h(){return(h=r(function*(r=!1){if(r&&(null==n?void 0:n.REQI))for(let t of n.REQI)f=yield t(f);try{return yield t(f)}catch(o){let t="GET"===f.method||f.isGet,r=typeof a,n="undefined"===r?t:"function"===r?a(f,o):!!a;if(l===s||!n)throw o;let e="function"==typeof c?c(s):c;return e&&e>0&&s>0&&(yield new Promise(t=>{setTimeout(()=>{t("ok")},e)})),s++,y&&y(f,o,s),p(!0)}})).apply(this,arguments)}return p()})}}export{e as default};

@@ -1,55 +0,1 @@

interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {
url?: string;
headers?: Record<string, any>;
baseURL?: string;
params?: Record<string, any>;
/** If no set, default depends on browsers timeout */
timeout?: number;
paramsSerializer?: (params: Record<string, any>) => string;
/** Use encodeURIComponent, default: true */
encodeURI?: boolean;
/**
* Currently only support 'json' | 'text', default: 'json';
* Others will just return the original response
*/
responseType?: 'json' | 'text' | 'stream' | 'document' | 'arraybuffer' | 'blob' | 'original';
data?: any;
/** encoded url with params */
_url?: string;
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;
}
type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & {
headers: Record<string, any>;
params: Record<string, any>;
url: string;
method: string;
};
interface XiorResponse<T = any> {
data: T;
status: number;
statusText: string;
headers: Headers;
response: Response;
config: XiorInterceptorRequestConfig;
request?: any;
}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
interface AsymmetricMatcher {
asymmetricMatch: (payload: any) => any;
}
type RequestOptions = XiorRequestConfig & {
headers?: AsymmetricMatcher | Record<string, string>;
params?: AsymmetricMatcher | Record<string, any>;
data?: AsymmetricMatcher | Record<string, any>;
};
type RequestData<T> = null | string | boolean | any[] | number | AsymmetricMatcher | Record<string, any>;
type MockHeaders = Record<string, any>;
type StatusOrCallback = number | ((config: XiorRequestConfig) => any | any[] | Promise<any[]>);
declare class XiorError extends Error {

@@ -157,4 +103,6 @@ request?: XiorRequestConfig;

fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
createGet<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
createPost<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {

@@ -178,2 +126,56 @@ /** @deprecated No `data` in `GET` method */

interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {
url?: string;
headers?: Record<string, any>;
baseURL?: string;
params?: Record<string, any>;
/** If no set, default depends on browsers timeout */
timeout?: number;
paramsSerializer?: (params: Record<string, any>) => string;
/** Use encodeURIComponent, default: true */
encodeURI?: boolean;
/**
* Currently only support 'json' | 'text', default: 'json';
* Others will just return the original response
*/
responseType?: 'json' | 'text' | 'stream' | 'document' | 'arraybuffer' | 'blob' | 'original';
data?: any;
/** encoded url with params */
_url?: string;
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;
}
type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & {
headers: Record<string, any>;
params: Record<string, any>;
url: string;
method: string;
};
interface XiorResponse<T = any> {
data: T;
status: number;
statusText: string;
headers: Headers;
response: Response;
config: XiorInterceptorRequestConfig;
request?: any;
}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
interface AsymmetricMatcher {
asymmetricMatch: (payload: any) => any;
}
type RequestOptions = XiorRequestConfig & {
headers?: AsymmetricMatcher | Record<string, string>;
params?: AsymmetricMatcher | Record<string, any>;
data?: AsymmetricMatcher | Record<string, any>;
};
type RequestData<T> = null | string | boolean | any[] | number | AsymmetricMatcher | Record<string, any>;
type MockHeaders = Record<string, any>;
type StatusOrCallback = number | ((config: XiorRequestConfig) => any | any[] | Promise<any[]>);
interface MockOptions {

@@ -180,0 +182,0 @@ delayResponse?: number;

@@ -1,55 +0,1 @@

interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {
url?: string;
headers?: Record<string, any>;
baseURL?: string;
params?: Record<string, any>;
/** If no set, default depends on browsers timeout */
timeout?: number;
paramsSerializer?: (params: Record<string, any>) => string;
/** Use encodeURIComponent, default: true */
encodeURI?: boolean;
/**
* Currently only support 'json' | 'text', default: 'json';
* Others will just return the original response
*/
responseType?: 'json' | 'text' | 'stream' | 'document' | 'arraybuffer' | 'blob' | 'original';
data?: any;
/** encoded url with params */
_url?: string;
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;
}
type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & {
headers: Record<string, any>;
params: Record<string, any>;
url: string;
method: string;
};
interface XiorResponse<T = any> {
data: T;
status: number;
statusText: string;
headers: Headers;
response: Response;
config: XiorInterceptorRequestConfig;
request?: any;
}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
interface AsymmetricMatcher {
asymmetricMatch: (payload: any) => any;
}
type RequestOptions = XiorRequestConfig & {
headers?: AsymmetricMatcher | Record<string, string>;
params?: AsymmetricMatcher | Record<string, any>;
data?: AsymmetricMatcher | Record<string, any>;
};
type RequestData<T> = null | string | boolean | any[] | number | AsymmetricMatcher | Record<string, any>;
type MockHeaders = Record<string, any>;
type StatusOrCallback = number | ((config: XiorRequestConfig) => any | any[] | Promise<any[]>);
declare class XiorError extends Error {

@@ -157,4 +103,6 @@ request?: XiorRequestConfig;

fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
createGet<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
createPost<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {

@@ -178,2 +126,56 @@ /** @deprecated No `data` in `GET` method */

interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {
url?: string;
headers?: Record<string, any>;
baseURL?: string;
params?: Record<string, any>;
/** If no set, default depends on browsers timeout */
timeout?: number;
paramsSerializer?: (params: Record<string, any>) => string;
/** Use encodeURIComponent, default: true */
encodeURI?: boolean;
/**
* Currently only support 'json' | 'text', default: 'json';
* Others will just return the original response
*/
responseType?: 'json' | 'text' | 'stream' | 'document' | 'arraybuffer' | 'blob' | 'original';
data?: any;
/** encoded url with params */
_url?: string;
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;
}
type XiorInterceptorRequestConfig<T = any> = XiorRequestConfig & {
headers: Record<string, any>;
params: Record<string, any>;
url: string;
method: string;
};
interface XiorResponse<T = any> {
data: T;
status: number;
statusText: string;
headers: Headers;
response: Response;
config: XiorInterceptorRequestConfig;
request?: any;
}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
interface AsymmetricMatcher {
asymmetricMatch: (payload: any) => any;
}
type RequestOptions = XiorRequestConfig & {
headers?: AsymmetricMatcher | Record<string, string>;
params?: AsymmetricMatcher | Record<string, any>;
data?: AsymmetricMatcher | Record<string, any>;
};
type RequestData<T> = null | string | boolean | any[] | number | AsymmetricMatcher | Record<string, any>;
type MockHeaders = Record<string, any>;
type StatusOrCallback = number | ((config: XiorRequestConfig) => any | any[] | Promise<any[]>);
interface MockOptions {

@@ -180,0 +182,0 @@ delayResponse?: number;

@@ -0,1 +1,125 @@

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -41,3 +165,3 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -44,0 +168,0 @@ interface XiorProgressOptions {

@@ -0,1 +1,125 @@

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -41,3 +165,3 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -44,0 +168,0 @@ interface XiorProgressOptions {

@@ -10,2 +10,126 @@ type ICacheLike<T> = {

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -51,3 +175,3 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -54,0 +178,0 @@ type XiorPromise = Promise<XiorResponse>;

@@ -10,2 +10,126 @@ type ICacheLike<T> = {

declare class XiorError extends Error {
request?: XiorRequestConfig;
config?: XiorRequestConfig;
response?: XiorResponse;
constructor(message: string, request?: XiorRequestConfig, response?: XiorResponse);
}
type XiorInstance = xior;
declare class xior {
static create(options?: XiorRequestConfig): XiorInstance;
static VERSION: string;
config?: XiorRequestConfig;
defaults: XiorInterceptorRequestConfig;
constructor(options?: XiorRequestConfig);
/** request interceptors */
REQI: ((config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig)[];
/** response interceptors */
RESI: {
fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
onRejected?: (error: XiorError) => any;
}[];
get interceptors(): {
request: {
use: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig, onRejected?: ((error: any) => any) | undefined) => (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig;
eject: (fn: (config: XiorInterceptorRequestConfig) => Promise<XiorInterceptorRequestConfig> | XiorInterceptorRequestConfig) => void;
clear: () => void;
};
response: {
use: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}, onRejected?: ((error: XiorError) => any) | undefined) => (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
};
eject: (fn: (config: {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => Promise<{
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}> | {
data: any;
config: XiorInterceptorRequestConfig;
request: XiorInterceptorRequestConfig;
response: Response;
}) => void;
clear: () => void;
};
};
/** plugins */
P: XiorPlugin[];
get plugins(): {
use: (plugin: XiorPlugin) => XiorPlugin;
eject: (plugin: XiorPlugin) => void;
clear: () => void;
};
request<T>(options?: XiorRequestConfig | string): Promise<XiorResponse<T>>;
fetch<T>(requestConfig: XiorRequestConfig): Promise<XiorResponse<T>>;
/** create get method */
cG<T>(method: string): (url: string, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
/** create post method */
cP<T>(method: string): (url: string, data?: any, options?: XiorRequestConfig) => Promise<XiorResponse<T>>;
get<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `GET` method */
data?: any;
}): Promise<XiorResponse<T>>;
head<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `HEAD` method */
data?: any;
}): Promise<XiorResponse<T>>;
post<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
put<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
patch<T = any>(url: string, data?: any, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
delete<T = any>(url: string, options?: XiorRequestConfig): Promise<XiorResponse<T>>;
options<T = any>(url: string, options?: XiorRequestConfig & {
/** @deprecated No `data` in `OPTIONS` method */
data?: any;
}): Promise<XiorResponse<T>>;
}
interface XiorRequestConfig<T = any> extends Omit<RequestInit, 'body'> {

@@ -51,3 +175,3 @@ url?: string;

}
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;
type XiorPlugin = (adapter: (request: XiorRequestConfig) => Promise<XiorResponse>, instance?: XiorInstance) => (request: XiorRequestConfig) => Promise<XiorResponse<any>>;

@@ -54,0 +178,0 @@ type XiorPromise = Promise<XiorResponse>;

@@ -120,3 +120,3 @@ [![Build](https://github.com/suhaotian/xior/actions/workflows/check.yml/badge.svg)](https://github.com/suhaotian/xior/actions/workflows/check.yml)

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.1/dist/xior.umd.js"></script>

@@ -136,3 +136,3 @@ <!-- Usage -->

```html
<script src="https://unpkg.com/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.1/dist/xior.umd.js"></script>

@@ -503,3 +503,3 @@ <!-- Usage -->

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.1/dist/xior.umd.js"></script>
<!-- Load plugin -->

@@ -519,3 +519,3 @@ <script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/plugins/error-retry.umd.js"></script>

```html
<script src="https://unpkg.com/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.1/dist/xior.umd.js"></script>

@@ -606,3 +606,3 @@ <!-- Load plugin -->

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.1/dist/xior.umd.js"></script>
<!-- Load plugin -->

@@ -622,3 +622,3 @@ <script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/plugins/throttle.umd.js"></script>

```html
<script src="https://unpkg.com/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.1/dist/xior.umd.js"></script>

@@ -674,3 +674,3 @@ <!-- Load plugin -->

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.1/dist/xior.umd.js"></script>
<!-- Load plugin -->

@@ -690,3 +690,3 @@ <script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/plugins/dedupe.umd.js"></script>

```html
<script src="https://unpkg.com/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.1/dist/xior.umd.js"></script>

@@ -752,3 +752,3 @@ <!-- Load plugin -->

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.1/dist/xior.umd.js"></script>
<!-- Load plugin -->

@@ -768,3 +768,3 @@ <script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/plugins/error-cache.umd.js"></script>

```html
<script src="https://unpkg.com/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.1/dist/xior.umd.js"></script>

@@ -907,3 +907,3 @@ <!-- Load plugin -->

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.1/dist/xior.umd.js"></script>
<!-- Load plugin -->

@@ -923,3 +923,3 @@ <script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/plugins/progress.umd.js"></script>

```html
<script src="https://unpkg.com/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.1/dist/xior.umd.js"></script>

@@ -1034,3 +1034,3 @@ <!-- Load plugin -->

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.1/dist/xior.umd.js"></script>
<!-- Load plugin -->

@@ -1050,3 +1050,3 @@ <script src="https://cdn.jsdelivr.net/npm/xior@0.2.6/plugins/mock.umd.js"></script>

```html
<script src="https://unpkg.com/xior@0.2.6/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.1/dist/xior.umd.js"></script>

@@ -1076,3 +1076,3 @@ <!-- Load plugin -->

const instance = xior.create();
instance.plugins.use(function logPlugin(adapter) {
instance.plugins.use(function logPlugin(adapter, instance) {
return async (config) => {

@@ -1079,0 +1079,0 @@ const start = Date.now();

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

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

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

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc