Socket
Socket
Sign inDemoInstall

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.7 to 0.3.8

2

dist/index.esm.js

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

import{merge as e,encodeParams as t,XiorTimeoutError as r,anySignal as n,isAbsoluteURL as i,joinPath as s,XiorError as o}from"xior/utils";export*from"xior/utils";function a(e,t,r,n,i,s,o){try{var a=e[s](o),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,i)}function u(){return(u=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 l="application/",c=`${l}x-www-form-urlencoded`,h=`${l}json`;function f(){var r;return r=function*(r){let n=r.paramsSerializer||t,i=!1!==r.encodeURI,s=r.method?r.method.toUpperCase():"GET",o=r.url||"",a=o,l=r.data,f=l,d=(null==r?void 0:r.headers)||{},p=r.params||{},y=function(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}(s);if(l&&!(l instanceof FormData)){let t="";if(null==r?void 0:r.headers){let e=Object.keys(r.headers).find(e=>"content-type"===e.toLowerCase());e&&(t=r.headers[e],r.headers["Content-Type"]=t,"Content-Type"!==e&&delete r.headers[e])}t||(t=y?c:h,d["Content-Type"]=t),y&&r.params&&(p=e({},l||{},p)),t===h?f=JSON.stringify(l):!y&&t===c&&l&&"object"==typeof l&&(f=n(l))}if(Object.keys(p).length>0){let e=n(p,i);o+=o.includes("?")?`&${e}`:`?${e}`}return u({},r,{data:l,_data:f,url:a,_url:o,method:s,headers:d,isGet:y})},(f=function(){var e=this,t=arguments;return new Promise(function(n,i){var s=r.apply(e,t);function o(e){a(s,n,i,o,u,"next",e)}function u(e){a(s,n,i,o,u,"throw",e)}o(void 0)})}).apply(this,arguments)}function d(e,t,r,n,i,s,o){try{var a=e[s](o),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,i)}function p(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var s=e.apply(t,r);function o(e){d(s,n,i,o,a,"next",e)}function a(e){d(s,n,i,o,a,"throw",e)}o(void 0)})}}function y(){return(y=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 v="undefined"!=typeof AbortController;class E{static create(e){return new E(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(r){var n=this;return p(function*(){let i=e({},n.config||{},n.defaults||{},"string"==typeof r?{url:r}:r||{},{headers:{},params:{}});for(let e of(i.paramsSerializer||(i.paramsSerializer=t),n.REQI))i=yield e(i);let s=n.fetch.bind(n);return n.P.forEach(e=>{s=e(s,n)}),s(i)})()}fetch(e){var t=this;return p(function*(){var a,u;let l,c;let h=yield function(e){return f.apply(this,arguments)}(e),{url:d,method:p,headers:E,timeout:m,signal:O,data:R,_data:g,_url:P,isGet:I}=h,S=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)t.indexOf(r=s[n])>=0||(i[r]=e[r]);return i}(h,["url","method","headers","timeout","signal","data","_data","_url","isGet"]);e._url=P;let T=[];if(m&&v){let t=new AbortController;c=setTimeout(()=>{t.abort(new r(`timeout of ${m}ms exceeded`,e))},m),T.push(t.signal)}O&&T.push(O),l=T[0],T.length>1&&(l=n(T,()=>{clearTimeout(c)}));let b=P||d||"";e.baseURL&&!i(b)&&(b=s(e.baseURL,b));let j=yield fetch(b,y({body:I?void 0:g},S,{signal:l,method:p,headers:E}));c&&clearTimeout(c),null==l||null==(a=l.clear)||a.call(l);let w={response:j,config:e,status:j.status,statusText:j.statusText,headers:j.headers};if(!j.ok){let r;try{(r=yield j.text())&&(r=JSON.parse(r))}catch(e){}let n=new o(j.status?`Request failed with status code ${j.status}`:"Network error",e,y({data:r},w));for(let e of t.RESI)if(e.onRejected){let t=yield e.onRejected(n);if(null==t?void 0:null==(u=t.response)?void 0:u.ok)return t}throw n}if("HEAD"===p)return y({data:void 0,request:e},w);let{responseType:x}=e;if(!x||["json","text"].includes(x)){let r;try{(r=yield j.text())&&"text"!==x&&(r=JSON.parse(r))}catch(e){}let n={data:r,config:e,request:e,response:j};for(let e of t.RESI)n=yield e.fn(n);return y({data:n.data,request:e},w)}return y({data:void 0,request:e},w)})()}cG(e){return(t,r)=>this.request(r?y({},r,{method:e,url:t}):{method:e,url:t})}cP(e){return(t,r,n)=>this.request(n?y({},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:{}}}}E.VERSION="0.3.7";let m=Object.assign(E.create(),{create:E.create,VERSION:E.VERSION});export{m as default,E as xior};
import{merge as e,encodeParams as t,XiorTimeoutError as r,anySignal as n,isAbsoluteURL as i,joinPath as s,XiorError as o}from"xior/utils";export*from"xior/utils";function a(e,t,r,n,i,s,o){try{var a=e[s](o),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,i)}function u(){return(u=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 l="application/",c=`${l}x-www-form-urlencoded`,h=`${l}json`;function f(){var r;return r=function*(r){let n=r.paramsSerializer||t,i=!1!==r.encodeURI,s=r.method?r.method.toUpperCase():"GET",o=r.url||"",a=o,l=r.data,f=l,d=(null==r?void 0:r.headers)||{},p=r.params||{},y=function(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}(s);if(l&&!(l instanceof FormData)){let t="";if(null==r?void 0:r.headers){let e=Object.keys(r.headers).find(e=>"content-type"===e.toLowerCase());e&&(t=r.headers[e],r.headers["Content-Type"]=t,"Content-Type"!==e&&delete r.headers[e])}t||(t=y?c:h,d["Content-Type"]=t),y&&r.params&&(p=e({},l||{},p)),t===h?f=JSON.stringify(l):!y&&t===c&&l&&"object"==typeof l&&(f=n(l))}if(Object.keys(p).length>0){let e=n(p,i);o+=o.includes("?")?`&${e}`:`?${e}`}return u({},r,{data:l,_data:f,url:a,_url:o,method:s,headers:d,isGet:y})},(f=function(){var e=this,t=arguments;return new Promise(function(n,i){var s=r.apply(e,t);function o(e){a(s,n,i,o,u,"next",e)}function u(e){a(s,n,i,o,u,"throw",e)}o(void 0)})}).apply(this,arguments)}function d(e,t,r,n,i,s,o){try{var a=e[s](o),u=a.value}catch(e){r(e);return}a.done?t(u):Promise.resolve(u).then(n,i)}function p(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var s=e.apply(t,r);function o(e){d(s,n,i,o,a,"next",e)}function a(e){d(s,n,i,o,a,"throw",e)}o(void 0)})}}function y(){return(y=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 v="undefined"!=typeof AbortController;class E{static create(e){return new E(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(r){var n=this;return p(function*(){let i=e({},n.config||{},n.defaults||{},"string"==typeof r?{url:r}:r||{},{headers:{},params:{}});for(let e of(i.paramsSerializer||(i.paramsSerializer=t),n.REQI))i=yield e(i);let s=n.fetch.bind(n);return n.P.forEach(e=>{s=e(s,n)}),s(i)})()}fetch(e){var t=this;return p(function*(){var a,u;let l,c;let h=yield function(e){return f.apply(this,arguments)}(e),{url:d,method:p,headers:E,timeout:m,signal:O,data:R,_data:g,_url:P,isGet:I}=h,S=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n<s.length;n++)t.indexOf(r=s[n])>=0||(i[r]=e[r]);return i}(h,["url","method","headers","timeout","signal","data","_data","_url","isGet"]);e._url=P;let T=[];if(m&&v){let t=new AbortController;c=setTimeout(()=>{t.abort(new r(`timeout of ${m}ms exceeded`,e))},m),T.push(t.signal)}O&&T.push(O),l=T[0],T.length>1&&(l=n(T,()=>{clearTimeout(c)}));let b=P||d||"";e.baseURL&&!i(b)&&(b=s(e.baseURL,b));let j=yield fetch(b,y({body:I?void 0:g},S,{signal:l,method:p,headers:E}));c&&clearTimeout(c),null==l||null==(a=l.clear)||a.call(l);let w={response:j,config:e,status:j.status,statusText:j.statusText,headers:j.headers};if(!j.ok){let r;try{(r=yield j.text())&&(r=JSON.parse(r))}catch(e){}let n=new o(j.status?`Request failed with status code ${j.status}`:"Network error",e,y({data:r},w));for(let e of t.RESI)if(e.onRejected){let t=yield e.onRejected(n);if(null==t?void 0:null==(u=t.response)?void 0:u.ok)return t}throw n}if("HEAD"===p)return y({data:void 0,request:e},w);let{responseType:x}=e;if(!x||["json","text"].includes(x)){let r;try{(r=yield j.text())&&"text"!==x&&(r=JSON.parse(r))}catch(e){}let n={data:r,config:e,request:e,response:j};for(let e of t.RESI)n=yield e.fn(n);return y({data:n.data,request:e},w)}return y({data:void 0,request:e},w)})()}cG(e){return(t,r)=>this.request(r?y({},r,{method:e,url:t}):{method:e,url:t})}cP(e){return(t,r,n)=>this.request(n?y({},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:{}}}}E.VERSION="0.3.8";let m=Object.assign(E.create(),{create:E.create,VERSION:E.VERSION});export{m as default,E as xior};

@@ -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,(()=>{return e={509:function(e,t,r){"use strict";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 s=r(895);n(r(895),t),n(r(340),t),n(r(121),t);const i=Object.assign(s.xior.create(),{create:s.xior.create,VERSION:s.xior.VERSION});t.default=i},393:function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,s){function i(e){try{u(o.next(e))}catch(e){s(e)}}function a(e){try{u(o.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.likeGET=void 0;const n=r(121),s="application/",i=`${s}x-www-form-urlencoded`,a=`${s}json`;function u(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}t.likeGET=u,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 s=e.url||"";const c=s,l=e.data;let d=l;const f=(null==e?void 0:e.headers)||{};let h=e.params||{};const p=u(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?i:a,f["Content-Type"]=r),p&&e.params&&(h=(0,n.merge)({},l||{},h)),r===a?d=JSON.stringify(l):!p&&r===i&&l&&"object"==typeof l&&(d=t(l))}if(Object.keys(h).length>0){const e=t(h,r);s+=s.includes("?")?`&${e}`:`?${e}`}return Object.assign(Object.assign({},e),{data:l,_data:d,url:c,_url:s,method:o,headers:f,isGet:p})}))}},340:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},895:function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,s){function i(e){try{u(o.next(e))}catch(e){s(e)}}function a(e){try{u(o.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((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},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.xior=void 0;const i=r(121),a=s(r(393)),u="undefined"!=typeof AbortController;class c{static create(e){return new c(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,i.merge)({},this.config||{},this.defaults||{},"string"==typeof e?{url:e}:e||{},{headers:{},params:{}});t.paramsSerializer||(t.paramsSerializer=i.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,a.default)(e),{url:s,method:c,headers:l,timeout:d,signal:f,data:h,_data:p,_url:y,isGet:m}=o,b=n(o,["url","method","headers","timeout","signal","data","_data","_url","isGet"]);let g;e._url=y;const O=[];let v;if(d&&u){const t=new AbortController;v=setTimeout((()=>{t.abort(new i.XiorTimeoutError(`timeout of ${d}ms exceeded`,e))}),d),O.push(t.signal)}f&&O.push(f),g=O[0],O.length>1&&(g=(0,i.anySignal)(O,(()=>{clearTimeout(v)})));let j=y||s||"";e.baseURL&&!(0,i.isAbsoluteURL)(j)&&(j=(0,i.joinPath)(e.baseURL,j));const E=yield fetch(j,Object.assign(Object.assign({body:m?void 0:p},b),{signal:g,method:c,headers:l}));v&&clearTimeout(v),null===(t=null==g?void 0:g.clear)||void 0===t||t.call(g);const P={response:E,config:e,status:E.status,statusText:E.statusText,headers:E.headers};if(!E.ok){let t;try{t=yield E.text(),t&&(t=JSON.parse(t))}catch(e){}const o=new i.XiorError(E.status?`Request failed with status code ${E.status}`:"Network error",e,Object.assign({data:t},P));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"===c)return Object.assign({data:void 0,request:e},P);const{responseType:_}=e;if(!_||["json","text"].includes(_)){let t;try{t=yield E.text(),t&&"text"!==_&&(t=JSON.parse(t))}catch(e){}let r={data:t,config:e,request:e,response:E};for(const e of this.RESI)r=yield e.fn(r);return Object.assign({data:r.data,request:e},P)}return Object.assign({data:void 0,request:e},P)}))}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=c,c.VERSION="0.3.7"},602:(e,t)=>{"use strict";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}},121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var o=r(602);class n extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}}),t.XiorError=n,t.XiorTimeoutError=class extends n{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.anySignal=function(e,t){let r=new globalThis.AbortController;function o(e){r.abort(e),s()}let n=[];for(let t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){let e=()=>{o(t.reason)};n.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function s(){n.forEach((e=>{e()})),null==t||t()}let i=r.signal;return i.clear=s,i},t.buildSortedURL=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));let[n,s]=o.split("?");return s?`${n}?${s.split("&").sort().join("&")}`:o||e},t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))},t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";let n=[],s=r?encodeURIComponent:e=>e;for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i)){let a=t[i],u=o?`${o}[${s(i)}]`:s(i);if("object"==typeof a){let t=e(a,r,u);""!==t&&n.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{let r=`${u}[${t}]`;n.push(`${s(r)}=${s(e)}`)})):n.push(`${s(u)}=${s(a)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}}},t={},function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o].call(s.exports,s,s.exports,r),s.exports}(509).default;var e,t}));
!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,(()=>{return e={509:function(e,t,r){"use strict";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 s=r(895);n(r(895),t),n(r(340),t),n(r(121),t);const i=Object.assign(s.xior.create(),{create:s.xior.create,VERSION:s.xior.VERSION});t.default=i},393:function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,s){function i(e){try{u(o.next(e))}catch(e){s(e)}}function a(e){try{u(o.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.likeGET=void 0;const n=r(121),s="application/",i=`${s}x-www-form-urlencoded`,a=`${s}json`;function u(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}t.likeGET=u,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 s=e.url||"";const c=s,l=e.data;let d=l;const f=(null==e?void 0:e.headers)||{};let h=e.params||{};const p=u(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?i:a,f["Content-Type"]=r),p&&e.params&&(h=(0,n.merge)({},l||{},h)),r===a?d=JSON.stringify(l):!p&&r===i&&l&&"object"==typeof l&&(d=t(l))}if(Object.keys(h).length>0){const e=t(h,r);s+=s.includes("?")?`&${e}`:`?${e}`}return Object.assign(Object.assign({},e),{data:l,_data:d,url:c,_url:s,method:o,headers:f,isGet:p})}))}},340:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},895:function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,s){function i(e){try{u(o.next(e))}catch(e){s(e)}}function a(e){try{u(o.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}u((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},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.xior=void 0;const i=r(121),a=s(r(393)),u="undefined"!=typeof AbortController;class c{static create(e){return new c(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,i.merge)({},this.config||{},this.defaults||{},"string"==typeof e?{url:e}:e||{},{headers:{},params:{}});t.paramsSerializer||(t.paramsSerializer=i.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,a.default)(e),{url:s,method:c,headers:l,timeout:d,signal:f,data:h,_data:p,_url:y,isGet:m}=o,b=n(o,["url","method","headers","timeout","signal","data","_data","_url","isGet"]);let g;e._url=y;const O=[];let v;if(d&&u){const t=new AbortController;v=setTimeout((()=>{t.abort(new i.XiorTimeoutError(`timeout of ${d}ms exceeded`,e))}),d),O.push(t.signal)}f&&O.push(f),g=O[0],O.length>1&&(g=(0,i.anySignal)(O,(()=>{clearTimeout(v)})));let j=y||s||"";e.baseURL&&!(0,i.isAbsoluteURL)(j)&&(j=(0,i.joinPath)(e.baseURL,j));const E=yield fetch(j,Object.assign(Object.assign({body:m?void 0:p},b),{signal:g,method:c,headers:l}));v&&clearTimeout(v),null===(t=null==g?void 0:g.clear)||void 0===t||t.call(g);const P={response:E,config:e,status:E.status,statusText:E.statusText,headers:E.headers};if(!E.ok){let t;try{t=yield E.text(),t&&(t=JSON.parse(t))}catch(e){}const o=new i.XiorError(E.status?`Request failed with status code ${E.status}`:"Network error",e,Object.assign({data:t},P));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"===c)return Object.assign({data:void 0,request:e},P);const{responseType:_}=e;if(!_||["json","text"].includes(_)){let t;try{t=yield E.text(),t&&"text"!==_&&(t=JSON.parse(t))}catch(e){}let r={data:t,config:e,request:e,response:E};for(const e of this.RESI)r=yield e.fn(r);return Object.assign({data:r.data,request:e},P)}return Object.assign({data:void 0,request:e},P)}))}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=c,c.VERSION="0.3.8"},602:(e,t)=>{"use strict";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}},121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var o=r(602);class n extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}}),t.XiorError=n,t.XiorTimeoutError=class extends n{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.anySignal=function(e,t){let r=new globalThis.AbortController;function o(e){r.abort(e),s()}let n=[];for(let t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){let e=()=>{o(t.reason)};n.push((()=>{null!=(null==t?void 0:t.removeEventListener)&&t.removeEventListener("abort",e)})),t.addEventListener("abort",e)}}function s(){n.forEach((e=>{e()})),null==t||t()}let i=r.signal;return i.clear=s,i},t.buildSortedURL=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));let[n,s]=o.split("?");return s?`${n}?${s.split("&").sort().join("&")}`:o||e},t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))},t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";let n=[],s=r?encodeURIComponent:e=>e;for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i)){let a=t[i],u=o?`${o}[${s(i)}]`:s(i);if("object"==typeof a){let t=e(a,r,u);""!==t&&n.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{let r=`${u}[${t}]`;n.push(`${s(r)}=${s(e)}`)})):n.push(`${s(u)}=${s(a)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}}},t={},function r(o){var n=t[o];if(void 0!==n)return n.exports;var s=t[o]={exports:{}};return e[o].call(s.exports,s,s.exports,r),s.exports}(509).default;var e,t}));

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

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

@@ -83,4 +83,4 @@ <!-- Usage -->

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

@@ -87,0 +87,0 @@ <!-- Usage -->

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

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

/*! For license information please see cache.umd.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.xiorCache=e():t.xiorCache=e()}(this,(()=>{return t={523:function(t,e,r){"use strict";var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(s,n){function o(t){try{u(i.next(t))}catch(t){n(t)}}function l(t){try{u(i.throw(t))}catch(t){n(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,l)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const s=r(455),n=r(121);e.default=function(t={}){const{enableCache:e,defaultCache:r=(0,s.lru)(100,3e5)}=t;return function(t){return s=>i(this,void 0,void 0,(function*(){const{enableCache:o=e,forceUpdate:l,defaultCache:u=r,paramsSerializer:a}=s,h="GET"===s.method||s.isGet,c=typeof o;if("undefined"===c?h:"function"===c?o(s):Boolean(o)){const e=u,r=(0,n.buildSortedURL)(s.url&&(0,n.isAbsoluteURL)(s.url)?s.url:(0,n.joinPath)(s.baseURL||"",s.url||""),{a:s.data,b:s.params},a);let o=e.get(r);return!o||l?(o=(()=>i(this,void 0,void 0,(function*(){try{return yield t(s)}catch(t){throw"delete"in e?e.delete(r):e.del(r),t}})))(),e.set(r,o),o):o.then((t=>(t.fromCache=!0,t)))}return t(s)}))}}},455:(t,e)=>{"use strict";class r{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,i=this.resetTtl){let s;if(r||this.has(t)){if(s=this.items[t],s.value=e,!1===r&&i&&(s.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==s){const t=this.last,e=s.next,r=s.prev;this.first===s&&(this.first=s.next),s.next=null,s.prev=this.last,t.next=s,null!==r&&(r.next=e),null!==e&&(e.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=s:this.last.next=s;return this.last=s,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}e.LRU=r,e.lru=function(t=1e3,e=0,i=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new r(t,e,i)}},602:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.merge=void 0;const r=t=>{if("object"==typeof t&&null!==t){if("function"==typeof Object.getPrototypeOf){const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"===Object.prototype.toString.call(t)}return!1};e.merge=(...t)=>t.reduce(((t,i)=>{if(Array.isArray(i))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(i).forEach((s=>{["__proto__","constructor","prototype"].includes(s)||(Array.isArray(t[s])&&Array.isArray(i[s])?t[s]=e.merge.options.mergeArrays?e.merge.options.uniqueArrayItems?Array.from(new Set(t[s].concat(i[s]))):[...t[s],...i[s]]:i[s]:r(t[s])&&r(i[s])?t[s]=(0,e.merge)(t[s],i[s]):t[s]=void 0===i[s]?e.merge.options.allowUndefinedOverrides?i[s]:t[s]:i[s])})),t}),{});const i={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};e.merge.options=i,e.merge.withOptions=(t,...r)=>{e.merge.options=Object.assign(Object.assign({},i),t);const s=(0,e.merge)(...r);return e.merge.options=i,s}},121:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var i=r(602);class s extends Error{constructor(t,e,r){super(t),this.name="XiorError",this.request=e,this.config=e,this.response=r}}Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return i.merge}}),e.XiorError=s,e.XiorTimeoutError=class extends s{constructor(t,e,r){super(t),this.name="XiorTimeoutError",this.request=e,this.config=e,this.response=r}},e.anySignal=function(t,e){let r=new globalThis.AbortController;function i(t){r.abort(t),n()}let s=[];for(let e of t){if(!0===(null==e?void 0:e.aborted)){i(e.reason);break}if(null!=(null==e?void 0:e.addEventListener)){let t=()=>{i(e.reason)};s.push((()=>{null!=(null==e?void 0:e.removeEventListener)&&e.removeEventListener("abort",t)})),e.addEventListener("abort",t)}}function n(){s.forEach((t=>{t()})),null==e||e()}let o=r.signal;return o.clear=n,o},e.buildSortedURL=function(t,e,r){let i=e?r(e):"";i&&(i=t+(t.includes("?")?"&"+i:"?"+i));let[s,n]=i.split("?");return n?`${s}?${n.split("&").sort().join("&")}`:i||t},e.delay=function(t){return new Promise((e=>{setTimeout((()=>{e("ok")}),t)}))},e.encodeParams=function t(e,r=!0,i=null){if(null==e)return"";let s=[],n=r?encodeURIComponent:t=>t;for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let l=e[o],u=i?`${i}[${n(o)}]`:n(o);if("object"==typeof l){let e=t(l,r,u);""!==e&&s.push(e)}else Array.isArray(l)?l.forEach(((t,e)=>{let r=`${u}[${e}]`;s.push(`${n(r)}=${n(t)}`)})):s.push(`${n(u)}=${n(l)}`)}return s.join("&")},e.isAbsoluteURL=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},e.isXiorError=function(t){return"XiorError"===t.name||"XiorTimeoutError"===t.name},e.joinPath=function(t,e){return e?(t.endsWith("/")?t:t+"/")+(e.startsWith("/")?e.slice(1):e):t}}},e={},function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,r),n.exports}(523).default;var t,e}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.xiorCache=e():t.xiorCache=e()}(this,(()=>{return t={523:function(t,e,r){"use strict";var i=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))((function(s,n){function o(t){try{u(i.next(t))}catch(t){n(t)}}function l(t){try{u(i.throw(t))}catch(t){n(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,l)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const s=r(455),n=r(121);e.default=function(t={}){const{enableCache:e,defaultCache:r=(0,s.lru)(100,3e5)}=t;return function(t){return s=>i(this,void 0,void 0,(function*(){const{enableCache:o=e,forceUpdate:l,defaultCache:u=r,paramsSerializer:a}=s,h="GET"===s.method||s.isGet,c=typeof o;let f;if("function"===c&&(f=o(s)),void 0===f&&(f="undefined"===c?h:Boolean(o)),f){const e=u,r=(0,n.buildSortedURL)(s.url&&(0,n.isAbsoluteURL)(s.url)?s.url:(0,n.joinPath)(s.baseURL||"",s.url||""),{a:s.data,b:s.params},a);let o=e.get(r);return!o||l?(o=(()=>i(this,void 0,void 0,(function*(){try{return yield t(s)}catch(t){throw"delete"in e?e.delete(r):e.del(r),t}})))(),e.set(r,o),o):o.then((t=>(t.fromCache=!0,t)))}return t(s)}))}}},455:(t,e)=>{"use strict";class r{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,i=this.resetTtl){let s;if(r||this.has(t)){if(s=this.items[t],s.value=e,!1===r&&i&&(s.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==s){const t=this.last,e=s.next,r=s.prev;this.first===s&&(this.first=s.next),s.next=null,s.prev=this.last,t.next=s,null!==r&&(r.next=e),null!==e&&(e.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=s:this.last.next=s;return this.last=s,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}e.LRU=r,e.lru=function(t=1e3,e=0,i=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new r(t,e,i)}},602:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.merge=void 0;const r=t=>{if("object"==typeof t&&null!==t){if("function"==typeof Object.getPrototypeOf){const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"===Object.prototype.toString.call(t)}return!1};e.merge=(...t)=>t.reduce(((t,i)=>{if(Array.isArray(i))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(i).forEach((s=>{["__proto__","constructor","prototype"].includes(s)||(Array.isArray(t[s])&&Array.isArray(i[s])?t[s]=e.merge.options.mergeArrays?e.merge.options.uniqueArrayItems?Array.from(new Set(t[s].concat(i[s]))):[...t[s],...i[s]]:i[s]:r(t[s])&&r(i[s])?t[s]=(0,e.merge)(t[s],i[s]):t[s]=void 0===i[s]?e.merge.options.allowUndefinedOverrides?i[s]:t[s]:i[s])})),t}),{});const i={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};e.merge.options=i,e.merge.withOptions=(t,...r)=>{e.merge.options=Object.assign(Object.assign({},i),t);const s=(0,e.merge)(...r);return e.merge.options=i,s}},121:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var i=r(602);class s extends Error{constructor(t,e,r){super(t),this.name="XiorError",this.request=e,this.config=e,this.response=r}}Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return i.merge}}),e.XiorError=s,e.XiorTimeoutError=class extends s{constructor(t,e,r){super(t),this.name="XiorTimeoutError",this.request=e,this.config=e,this.response=r}},e.anySignal=function(t,e){let r=new globalThis.AbortController;function i(t){r.abort(t),n()}let s=[];for(let e of t){if(!0===(null==e?void 0:e.aborted)){i(e.reason);break}if(null!=(null==e?void 0:e.addEventListener)){let t=()=>{i(e.reason)};s.push((()=>{null!=(null==e?void 0:e.removeEventListener)&&e.removeEventListener("abort",t)})),e.addEventListener("abort",t)}}function n(){s.forEach((t=>{t()})),null==e||e()}let o=r.signal;return o.clear=n,o},e.buildSortedURL=function(t,e,r){let i=e?r(e):"";i&&(i=t+(t.includes("?")?"&"+i:"?"+i));let[s,n]=i.split("?");return n?`${s}?${n.split("&").sort().join("&")}`:i||t},e.delay=function(t){return new Promise((e=>{setTimeout((()=>{e("ok")}),t)}))},e.encodeParams=function t(e,r=!0,i=null){if(null==e)return"";let s=[],n=r?encodeURIComponent:t=>t;for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let l=e[o],u=i?`${i}[${n(o)}]`:n(o);if("object"==typeof l){let e=t(l,r,u);""!==e&&s.push(e)}else Array.isArray(l)?l.forEach(((t,e)=>{let r=`${u}[${e}]`;s.push(`${n(r)}=${n(t)}`)})):s.push(`${n(u)}=${n(l)}`)}return s.join("&")},e.isAbsoluteURL=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},e.isXiorError=function(t){return"XiorError"===t.name||"XiorTimeoutError"===t.name},e.joinPath=function(t,e){return e?(t.endsWith("/")?t:t+"/")+(e.startsWith("/")?e.slice(1):e):t}}},e={},function r(i){var s=e[i];if(void 0!==s)return s.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,r),n.exports}(523).default;var t,e}));

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

import{lru as e}from"tiny-lru";import{buildSortedURL as t,isAbsoluteURL as n,joinPath as r}from"xior/utils";function u(e,t,n,r,u,o,i){try{var a=e[o](i),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(r,u)}function o(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){u(i,r,o,a,l,"next",e)}function l(e){u(i,r,o,a,l,"throw",e)}a(void 0)})}}function i(u={}){let{enableCache:i,defaultCache:a=e(100,3e5)}=u;return function(e){return o(function*(u){let{enableCache:l=i,forceUpdate:c,defaultCache:f=a,paramsSerializer:d}=u,h="GET"===u.method||u.isGet,s=typeof l;if("undefined"===s?h:"function"===s?l(u):!!l){let i=t(u.url&&n(u.url)?u.url:r(u.baseURL||"",u.url||""),{a:u.data,b:u.params},d),a=f.get(i);return!a||c?(a=o(function*(){try{return yield e(u)}catch(e){throw"delete"in f?f.delete(i):f.del(i),e}})(),f.set(i,a),a):a.then(e=>(e.fromCache=!0,e))}return e(u)})}}export{i as default};
import{lru as e}from"tiny-lru";import{buildSortedURL as t,isAbsoluteURL as n,joinPath as r}from"xior/utils";function u(e,t,n,r,u,o,i){try{var a=e[o](i),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(r,u)}function o(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){u(i,r,o,a,l,"next",e)}function l(e){u(i,r,o,a,l,"throw",e)}a(void 0)})}}function i(u={}){let{enableCache:i,defaultCache:a=e(100,3e5)}=u;return function(e){return o(function*(u){let l;let{enableCache:c=i,forceUpdate:f,defaultCache:d=a,paramsSerializer:h}=u,s="GET"===u.method||u.isGet,m=typeof c;if("function"===m&&(l=c(u)),void 0===l&&(l="undefined"===m?s:!!c),l){let i=t(u.url&&n(u.url)?u.url:r(u.baseURL||"",u.url||""),{a:u.data,b:u.params},h),a=d.get(i);return!a||f?(a=o(function*(){try{return yield e(u)}catch(e){throw"delete"in d?d.delete(i):d.del(i),e}})(),d.set(i,a),a):a.then(e=>(e.fromCache=!0,e))}return e(u)})}}export{i as default};

@@ -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.xiorDedupe=t():e.xiorDedupe=t()}(this,(()=>{return e={91:function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function u(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.inflight=void 0;const n=r(121);t.inflight=new Map,t.default=function(e={}){const{enableDedupe:r,onDedupe:i}=e;return function(e){return s=>o(this,void 0,void 0,(function*(){var o,u;const{paramsSerializer:l,enableDedupe:a=r,onDedupe:c=i}=s,f="GET"===s.method||s.isGet,d=typeof a;if(!("undefined"===d?f:"function"===d?a(s):Boolean(a)))return e(s);const p=(0,n.buildSortedURL)(s.url&&(0,n.isAbsoluteURL)(s.url)?s.url:(0,n.joinPath)(s.baseURL||"",s.url||""),{a:s.data,b:s.params},l);if(t.inflight.has(p))return c&&c(s),new Promise(((e,r)=>{var o;null===(o=t.inflight.get(p))||void 0===o||o.push([e,r])}));t.inflight.set(p,[]);try{const r=yield e(s);return null===(o=t.inflight.get(p))||void 0===o||o.forEach((([e])=>e(r))),t.inflight.delete(p),r}catch(e){throw null===(u=t.inflight.get(p))||void 0===u||u.forEach((([,t])=>t(e))),t.inflight.delete(p),e}}))}}},602:(e,t)=>{"use strict";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}},121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var o=r(602);class n extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}}),t.XiorError=n,t.XiorTimeoutError=class extends n{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.anySignal=function(e,t){let r=new globalThis.AbortController;function o(e){r.abort(e),i()}let n=[];for(let t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){let 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()}let s=r.signal;return s.clear=i,s},t.buildSortedURL=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));let[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e},t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))},t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";let n=[],i=r?encodeURIComponent:e=>e;for(let s in t)if(Object.prototype.hasOwnProperty.call(t,s)){let u=t[s],l=o?`${o}[${i(s)}]`:i(s);if("object"==typeof u){let t=e(u,r,l);""!==t&&n.push(t)}else Array.isArray(u)?u.forEach(((e,t)=>{let r=`${l}[${t}]`;n.push(`${i(r)}=${i(e)}`)})):n.push(`${i(l)}=${i(u)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}}},t={},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}(91).default;var e,t}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorDedupe=t():e.xiorDedupe=t()}(this,(()=>{return e={91:function(e,t,r){"use strict";var o=this&&this.__awaiter||function(e,t,r,o){return new(r||(r=Promise))((function(n,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function u(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,u)}l((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.inflight=void 0;const n=r(121);t.inflight=new Map,t.default=function(e={}){const{enableDedupe:r,onDedupe:i}=e;return function(e){return s=>o(this,void 0,void 0,(function*(){var o,u;const{paramsSerializer:l,enableDedupe:a=r,onDedupe:c=i}=s,f="GET"===s.method||s.isGet,d=typeof a;let p;if("function"===d&&(p=a(s)),void 0===p&&(p="undefined"===d?f:Boolean(a)),!p)return e(s);const h=(0,n.buildSortedURL)(s.url&&(0,n.isAbsoluteURL)(s.url)?s.url:(0,n.joinPath)(s.baseURL||"",s.url||""),{a:s.data,b:s.params},l);if(t.inflight.has(h))return c&&c(s),new Promise(((e,r)=>{var o;null===(o=t.inflight.get(h))||void 0===o||o.push([e,r])}));t.inflight.set(h,[]);try{const r=yield e(s);return null===(o=t.inflight.get(h))||void 0===o||o.forEach((([e])=>e(r))),t.inflight.delete(h),r}catch(e){throw null===(u=t.inflight.get(h))||void 0===u||u.forEach((([,t])=>t(e))),t.inflight.delete(h),e}}))}}},602:(e,t)=>{"use strict";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}},121:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0});var o=r(602);class n extends Error{constructor(e,t,r){super(e),this.name="XiorError",this.request=t,this.config=t,this.response=r}}Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return o.merge}}),t.XiorError=n,t.XiorTimeoutError=class extends n{constructor(e,t,r){super(e),this.name="XiorTimeoutError",this.request=t,this.config=t,this.response=r}},t.anySignal=function(e,t){let r=new globalThis.AbortController;function o(e){r.abort(e),i()}let n=[];for(let t of e){if(!0===(null==t?void 0:t.aborted)){o(t.reason);break}if(null!=(null==t?void 0:t.addEventListener)){let 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()}let s=r.signal;return s.clear=i,s},t.buildSortedURL=function(e,t,r){let o=t?r(t):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));let[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e},t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t("ok")}),e)}))},t.encodeParams=function e(t,r=!0,o=null){if(null==t)return"";let n=[],i=r?encodeURIComponent:e=>e;for(let s in t)if(Object.prototype.hasOwnProperty.call(t,s)){let u=t[s],l=o?`${o}[${i(s)}]`:i(s);if("object"==typeof u){let t=e(u,r,l);""!==t&&n.push(t)}else Array.isArray(u)?u.forEach(((e,t)=>{let r=`${l}[${t}]`;n.push(`${i(r)}=${i(e)}`)})):n.push(`${i(l)}=${i(u)}`)}return n.join("&")},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name},t.joinPath=function(e,t){return t?(e.endsWith("/")?e:e+"/")+(t.startsWith("/")?t.slice(1):t):e}}},t={},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}(91).default;var e,t}));

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

import{buildSortedURL as e,isAbsoluteURL as t,joinPath as n}from"xior/utils";function r(e,t,n,r,u,o,i){try{var l=e[o](i),a=l.value}catch(e){n(e);return}l.done?t(a):Promise.resolve(a).then(r,u)}let u=new Map;function o(o={}){let{enableDedupe:i,onDedupe:l}=o;return function(o){var a;return a=function*(r){var a,f;let{paramsSerializer:c,enableDedupe:d=i,onDedupe:s=l}=r,h="GET"===r.method||r.isGet,p=typeof d;if(!("undefined"===p?h:"function"===p?d(r):!!d))return o(r);let v=e(r.url&&t(r.url)?r.url:n(r.baseURL||"",r.url||""),{a:r.data,b:r.params},c);if(u.has(v))return s&&s(r),new Promise((e,t)=>{var n;null==(n=u.get(v))||n.push([e,t])});u.set(v,[]);try{let e=yield o(r);return null==(a=u.get(v))||a.forEach(([t])=>t(e)),u.delete(v),e}catch(e){throw null==(f=u.get(v))||f.forEach(([,t])=>t(e)),u.delete(v),e}},function(){var e=this,t=arguments;return new Promise(function(n,u){var o=a.apply(e,t);function i(e){r(o,n,u,i,l,"next",e)}function l(e){r(o,n,u,i,l,"throw",e)}i(void 0)})}}}export{o as default,u as inflight};
import{buildSortedURL as e,isAbsoluteURL as t,joinPath as n}from"xior/utils";function r(e,t,n,r,u,o,i){try{var l=e[o](i),a=l.value}catch(e){n(e);return}l.done?t(a):Promise.resolve(a).then(r,u)}let u=new Map;function o(o={}){let{enableDedupe:i,onDedupe:l}=o;return function(o){var a;return a=function*(r){var a,f;let c;let{paramsSerializer:d,enableDedupe:s=i,onDedupe:h=l}=r,p="GET"===r.method||r.isGet,v=typeof s;if("function"===v&&(c=s(r)),void 0===c&&(c="undefined"===v?p:!!s),!c)return o(r);let m=e(r.url&&t(r.url)?r.url:n(r.baseURL||"",r.url||""),{a:r.data,b:r.params},d);if(u.has(m))return h&&h(r),new Promise((e,t)=>{var n;null==(n=u.get(m))||n.push([e,t])});u.set(m,[]);try{let e=yield o(r);return null==(a=u.get(m))||a.forEach(([t])=>t(e)),u.delete(m),e}catch(e){throw null==(f=u.get(m))||f.forEach(([,t])=>t(e)),u.delete(m),e}},function(){var e=this,t=arguments;return new Promise(function(n,u){var o=a.apply(e,t);function i(e){r(o,n,u,i,l,"next",e)}function l(e){r(o,n,u,i,l,"throw",e)}i(void 0)})}}}export{o as default,u as inflight};

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

!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.xiorErrorCache=r():e.xiorErrorCache=r()}(this,(()=>{return e={431:function(e,r,t){"use strict";var o=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))((function(n,i){function s(e){try{a(o.next(e))}catch(e){i(e)}}function u(e){try{a(o.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,u)}a((o=o.apply(e,r||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0});const n=t(121),i={},s={get:e=>i[e],set(e,r){i[e]=r}};r.default=function(e={}){const{enableCache:r,defaultCache:t=s,useCacheFirst:i,onCacheRequest:u}=e;return function(e){return s=>o(this,void 0,void 0,(function*(){const{enableCache:a=r,defaultCache:l=t,useCacheFirst:c=i,onCacheRequest:d=u,paramsSerializer:f}=s,p="GET"===s.method||s.isGet,h=typeof a;if(!("undefined"===h?p:"function"===h?a(s):Boolean(a)))return e(s);const m=l,y=(0,n.buildSortedURL)(s.url&&(0,n.isAbsoluteURL)(s.url)?s.url:(0,n.joinPath)(s.baseURL||"",s.url||""),{a:s.data,b:s.params},f);try{if(c){const r=m.get(y);if(m.set(y,{loading:!0,res:null==r?void 0:r.res}),null==r?void 0:r.res)return(null==r?void 0:r.loading)||(null==d||d(s),(()=>{o(this,void 0,void 0,(function*(){try{const r=yield e(s);m.set(y,{loading:!1,res:r})}catch(e){const r=m.get(y);c&&m.set(y,{loading:!1,res:null==r?void 0:r.res})}}))})()),r.res.fromCache=!0,null==r?void 0:r.res}const r=yield e(s);return m.set(y,{loading:!1,res:r}),r}catch(e){const r=m.get(y);if(c&&m.set(y,{loading:!1,res:null==r?void 0:r.res}),null==r?void 0:r.res)return r.res.fromCache=!0,r.res.error=e,r.res;throw e}}))}}},602:(e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.merge=void 0;const t=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const r=Object.getPrototypeOf(e);return r===Object.prototype||null===r}return"[object Object]"===Object.prototype.toString.call(e)}return!1};r.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]=r.merge.options.mergeArrays?r.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:t(e[n])&&t(o[n])?e[n]=(0,r.merge)(e[n],o[n]):e[n]=void 0===o[n]?r.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};r.merge.options=o,r.merge.withOptions=(e,...t)=>{r.merge.options=Object.assign(Object.assign({},o),e);const n=(0,r.merge)(...t);return r.merge.options=o,n}},121:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0});var o=t(602);class n extends Error{constructor(e,r,t){super(e),this.name="XiorError",this.request=r,this.config=r,this.response=t}}Object.defineProperty(r,"merge",{enumerable:!0,get:function(){return o.merge}}),r.XiorError=n,r.XiorTimeoutError=class extends n{constructor(e,r,t){super(e),this.name="XiorTimeoutError",this.request=r,this.config=r,this.response=t}},r.anySignal=function(e,r){let t=new globalThis.AbortController;function o(e){t.abort(e),i()}let n=[];for(let r of e){if(!0===(null==r?void 0:r.aborted)){o(r.reason);break}if(null!=(null==r?void 0:r.addEventListener)){let e=()=>{o(r.reason)};n.push((()=>{null!=(null==r?void 0:r.removeEventListener)&&r.removeEventListener("abort",e)})),r.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==r||r()}let s=t.signal;return s.clear=i,s},r.buildSortedURL=function(e,r,t){let o=r?t(r):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));let[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e},r.delay=function(e){return new Promise((r=>{setTimeout((()=>{r("ok")}),e)}))},r.encodeParams=function e(r,t=!0,o=null){if(null==r)return"";let n=[],i=t?encodeURIComponent:e=>e;for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s)){let u=r[s],a=o?`${o}[${i(s)}]`:i(s);if("object"==typeof u){let r=e(u,t,a);""!==r&&n.push(r)}else Array.isArray(u)?u.forEach(((e,r)=>{let t=`${a}[${r}]`;n.push(`${i(t)}=${i(e)}`)})):n.push(`${i(a)}=${i(u)}`)}return n.join("&")},r.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},r.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name},r.joinPath=function(e,r){return r?(e.endsWith("/")?e:e+"/")+(r.startsWith("/")?r.slice(1):r):e}}},r={},function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o].call(i.exports,i,i.exports,t),i.exports}(431).default;var e,r}));
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.xiorErrorCache=r():e.xiorErrorCache=r()}(this,(()=>{return e={431:function(e,r,t){"use strict";var o=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))((function(n,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function u(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,u)}l((o=o.apply(e,r||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0});const n=t(121),i={},s={get:e=>i[e],set(e,r){i[e]=r}};r.default=function(e={}){const{enableCache:r,defaultCache:t=s,useCacheFirst:i,onCacheRequest:u}=e;return function(e){return s=>o(this,void 0,void 0,(function*(){const{enableCache:l=r,defaultCache:a=t,useCacheFirst:c=i,onCacheRequest:d=u,paramsSerializer:f}=s,p="GET"===s.method||s.isGet,h=typeof l;let m;if("function"===h&&(m=l(s)),void 0===m&&(m="undefined"===h?p:Boolean(l)),!m)return e(s);const y=a,g=(0,n.buildSortedURL)(s.url&&(0,n.isAbsoluteURL)(s.url)?s.url:(0,n.joinPath)(s.baseURL||"",s.url||""),{a:s.data,b:s.params},f);try{if(c){const r=y.get(g);if(y.set(g,{loading:!0,res:null==r?void 0:r.res}),null==r?void 0:r.res)return(null==r?void 0:r.loading)||(null==d||d(s),(()=>{o(this,void 0,void 0,(function*(){try{const r=yield e(s);y.set(g,{loading:!1,res:r})}catch(e){const r=y.get(g);c&&y.set(g,{loading:!1,res:null==r?void 0:r.res})}}))})()),r.res.fromCache=!0,null==r?void 0:r.res}const r=yield e(s);return y.set(g,{loading:!1,res:r}),r}catch(e){const r=y.get(g);if(c&&y.set(g,{loading:!1,res:null==r?void 0:r.res}),null==r?void 0:r.res)return r.res.fromCache=!0,r.res.error=e,r.res;throw e}}))}}},602:(e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.merge=void 0;const t=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const r=Object.getPrototypeOf(e);return r===Object.prototype||null===r}return"[object Object]"===Object.prototype.toString.call(e)}return!1};r.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]=r.merge.options.mergeArrays?r.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:t(e[n])&&t(o[n])?e[n]=(0,r.merge)(e[n],o[n]):e[n]=void 0===o[n]?r.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};r.merge.options=o,r.merge.withOptions=(e,...t)=>{r.merge.options=Object.assign(Object.assign({},o),e);const n=(0,r.merge)(...t);return r.merge.options=o,n}},121:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0});var o=t(602);class n extends Error{constructor(e,r,t){super(e),this.name="XiorError",this.request=r,this.config=r,this.response=t}}Object.defineProperty(r,"merge",{enumerable:!0,get:function(){return o.merge}}),r.XiorError=n,r.XiorTimeoutError=class extends n{constructor(e,r,t){super(e),this.name="XiorTimeoutError",this.request=r,this.config=r,this.response=t}},r.anySignal=function(e,r){let t=new globalThis.AbortController;function o(e){t.abort(e),i()}let n=[];for(let r of e){if(!0===(null==r?void 0:r.aborted)){o(r.reason);break}if(null!=(null==r?void 0:r.addEventListener)){let e=()=>{o(r.reason)};n.push((()=>{null!=(null==r?void 0:r.removeEventListener)&&r.removeEventListener("abort",e)})),r.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==r||r()}let s=t.signal;return s.clear=i,s},r.buildSortedURL=function(e,r,t){let o=r?t(r):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));let[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e},r.delay=function(e){return new Promise((r=>{setTimeout((()=>{r("ok")}),e)}))},r.encodeParams=function e(r,t=!0,o=null){if(null==r)return"";let n=[],i=t?encodeURIComponent:e=>e;for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s)){let u=r[s],l=o?`${o}[${i(s)}]`:i(s);if("object"==typeof u){let r=e(u,t,l);""!==r&&n.push(r)}else Array.isArray(u)?u.forEach(((e,r)=>{let t=`${l}[${r}]`;n.push(`${i(t)}=${i(e)}`)})):n.push(`${i(l)}=${i(u)}`)}return n.join("&")},r.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},r.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name},r.joinPath=function(e,r){return r?(e.endsWith("/")?e:e+"/")+(r.startsWith("/")?r.slice(1):r):e}}},r={},function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o].call(i.exports,i,i.exports,t),i.exports}(431).default;var e,r}));

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

import{buildSortedURL as e,isAbsoluteURL as r,joinPath as t}from"xior/utils";function n(e,r,t,n,l,o,i){try{var u=e[o](i),a=u.value}catch(e){t(e);return}u.done?r(a):Promise.resolve(a).then(n,l)}function l(e){return function(){var r=this,t=arguments;return new Promise(function(l,o){var i=e.apply(r,t);function u(e){n(i,l,o,u,a,"next",e)}function a(e){n(i,l,o,u,a,"throw",e)}u(void 0)})}}let o={},i={get:e=>o[e],set(e,r){o[e]=r}};function u(n={}){let{enableCache:o,defaultCache:u=i,useCacheFirst:a,onCacheRequest:s}=n;return function(n){return l(function*(i){let{enableCache:c=o,defaultCache:d=u,useCacheFirst:f=a,onCacheRequest:h=s,paramsSerializer:v}=i,g="GET"===i.method||i.isGet,m=typeof c;if(!("undefined"===m?g:"function"===m?c(i):!!c))return n(i);let y=e(i.url&&r(i.url)?i.url:t(i.baseURL||"",i.url||""),{a:i.data,b:i.params},v);try{if(f){let e=d.get(y);if(d.set(y,{loading:!0,res:null==e?void 0:e.res}),null==e?void 0:e.res)return(null==e?void 0:e.loading)||(null==h||h(i),l(function*(){try{let e=yield n(i);d.set(y,{loading:!1,res:e})}catch(r){let e=d.get(y);f&&d.set(y,{loading:!1,res:null==e?void 0:e.res})}})()),e.res.fromCache=!0,null==e?void 0:e.res}let e=yield n(i);return d.set(y,{loading:!1,res:e}),e}catch(r){let e=d.get(y);if(f&&d.set(y,{loading:!1,res:null==e?void 0:e.res}),null==e?void 0:e.res)return e.res.fromCache=!0,e.res.error=r,e.res;throw r}})}}export{u as default};
import{buildSortedURL as e,isAbsoluteURL as t,joinPath as r}from"xior/utils";function n(e,t,r,n,l,o,i){try{var u=e[o](i),a=u.value}catch(e){r(e);return}u.done?t(a):Promise.resolve(a).then(n,l)}function l(e){return function(){var t=this,r=arguments;return new Promise(function(l,o){var i=e.apply(t,r);function u(e){n(i,l,o,u,a,"next",e)}function a(e){n(i,l,o,u,a,"throw",e)}u(void 0)})}}let o={},i={get:e=>o[e],set(e,t){o[e]=t}};function u(n={}){let{enableCache:o,defaultCache:u=i,useCacheFirst:a,onCacheRequest:s}=n;return function(n){return l(function*(i){let c;let{enableCache:d=o,defaultCache:f=u,useCacheFirst:h=a,onCacheRequest:v=s,paramsSerializer:g}=i,m="GET"===i.method||i.isGet,y=typeof d;if("function"===y&&(c=d(i)),void 0===c&&(c="undefined"===y?m:!!d),!c)return n(i);let C=e(i.url&&t(i.url)?i.url:r(i.baseURL||"",i.url||""),{a:i.data,b:i.params},g);try{if(h){let e=f.get(C);if(f.set(C,{loading:!0,res:null==e?void 0:e.res}),null==e?void 0:e.res)return(null==e?void 0:e.loading)||(null==v||v(i),l(function*(){try{let e=yield n(i);f.set(C,{loading:!1,res:e})}catch(t){let e=f.get(C);h&&f.set(C,{loading:!1,res:null==e?void 0:e.res})}})()),e.res.fromCache=!0,null==e?void 0:e.res}let e=yield n(i);return f.set(C,{loading:!1,res:e}),e}catch(t){let e=f.get(C);if(h&&f.set(C,{loading:!1,res:null==e?void 0:e.res}),null==e?void 0:e.res)return e.res.fromCache=!0,e.res.error=t,e.res;throw t}})}}export{u as default};

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

!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.xiorErrorRetry=r():e.xiorErrorRetry=r()}(this,(()=>{return e={351:function(e,r,t){"use strict";var o=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function u(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,u)}c((o=o.apply(e,r||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0});const n=t(121);r.default=function(e={}){const{retryTimes:r,retryInterval:t,enableRetry:i,onRetry:s}=Object.assign({retryTimes:2,retryInterval:3e3},e||{});return function(e,u){return c=>o(this,void 0,void 0,(function*(){const{retryTimes:l=r,retryInterval:a=t,enableRetry:f=i,onRetry:d=s}=c;let y=!1,p=0;return function r(t=!1){return o(this,void 0,void 0,(function*(){if(t&&(null==u?void 0:u.REQI))for(const e of u.REQI)c=yield e(c);try{return yield e(c)}catch(e){const t="GET"===c.method||c.isGet,o=typeof f,i="undefined"===o?t:"function"===o?f(c,e):Boolean(f);if(y=l===p,y||!i)throw e;const s="function"==typeof a?a(p):a;return s&&s>0&&p>0&&(yield(0,n.delay)(s)),p++,d&&d(c,e,p),r(!0)}}))}()}))}}},602:(e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.merge=void 0;const t=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const r=Object.getPrototypeOf(e);return r===Object.prototype||null===r}return"[object Object]"===Object.prototype.toString.call(e)}return!1};r.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]=r.merge.options.mergeArrays?r.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:t(e[n])&&t(o[n])?e[n]=(0,r.merge)(e[n],o[n]):e[n]=void 0===o[n]?r.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};r.merge.options=o,r.merge.withOptions=(e,...t)=>{r.merge.options=Object.assign(Object.assign({},o),e);const n=(0,r.merge)(...t);return r.merge.options=o,n}},121:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0});var o=t(602);class n extends Error{constructor(e,r,t){super(e),this.name="XiorError",this.request=r,this.config=r,this.response=t}}Object.defineProperty(r,"merge",{enumerable:!0,get:function(){return o.merge}}),r.XiorError=n,r.XiorTimeoutError=class extends n{constructor(e,r,t){super(e),this.name="XiorTimeoutError",this.request=r,this.config=r,this.response=t}},r.anySignal=function(e,r){let t=new globalThis.AbortController;function o(e){t.abort(e),i()}let n=[];for(let r of e){if(!0===(null==r?void 0:r.aborted)){o(r.reason);break}if(null!=(null==r?void 0:r.addEventListener)){let e=()=>{o(r.reason)};n.push((()=>{null!=(null==r?void 0:r.removeEventListener)&&r.removeEventListener("abort",e)})),r.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==r||r()}let s=t.signal;return s.clear=i,s},r.buildSortedURL=function(e,r,t){let o=r?t(r):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));let[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e},r.delay=function(e){return new Promise((r=>{setTimeout((()=>{r("ok")}),e)}))},r.encodeParams=function e(r,t=!0,o=null){if(null==r)return"";let n=[],i=t?encodeURIComponent:e=>e;for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s)){let u=r[s],c=o?`${o}[${i(s)}]`:i(s);if("object"==typeof u){let r=e(u,t,c);""!==r&&n.push(r)}else Array.isArray(u)?u.forEach(((e,r)=>{let t=`${c}[${r}]`;n.push(`${i(t)}=${i(e)}`)})):n.push(`${i(c)}=${i(u)}`)}return n.join("&")},r.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},r.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name},r.joinPath=function(e,r){return r?(e.endsWith("/")?e:e+"/")+(r.startsWith("/")?r.slice(1):r):e}}},r={},function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o].call(i.exports,i,i.exports,t),i.exports}(351).default;var e,r}));
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.xiorErrorRetry=r():e.xiorErrorRetry=r()}(this,(()=>{return e={351:function(e,r,t){"use strict";var o=this&&this.__awaiter||function(e,r,t,o){return new(t||(t=Promise))((function(n,i){function s(e){try{c(o.next(e))}catch(e){i(e)}}function u(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var r;e.done?n(e.value):(r=e.value,r instanceof t?r:new t((function(e){e(r)}))).then(s,u)}c((o=o.apply(e,r||[])).next())}))};Object.defineProperty(r,"__esModule",{value:!0});const n=t(121);r.default=function(e={}){const{retryTimes:r,retryInterval:t,enableRetry:i,onRetry:s}=Object.assign({retryTimes:2,retryInterval:3e3},e||{});return function(e,u){return c=>o(this,void 0,void 0,(function*(){const{retryTimes:l=r,retryInterval:a=t,enableRetry:f=i,onRetry:d=s}=c;let y=!1,p=0;return function r(t=!1){return o(this,void 0,void 0,(function*(){if(t&&(null==u?void 0:u.REQI))for(const e of u.REQI)c=yield e(c);try{return yield e(c)}catch(e){const t="GET"===c.method||Boolean(c.isGet),o=typeof f;let i;if("function"===o&&(i=f(c,e)),void 0===i&&(i="undefined"===o?t:Boolean(f)),y=l===p,y||!i)throw e;const s="function"==typeof a?a(p):a;return s&&s>0&&p>0&&(yield(0,n.delay)(s)),p++,d&&d(c,e,p),r(!0)}}))}()}))}}},602:(e,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.merge=void 0;const t=e=>{if("object"==typeof e&&null!==e){if("function"==typeof Object.getPrototypeOf){const r=Object.getPrototypeOf(e);return r===Object.prototype||null===r}return"[object Object]"===Object.prototype.toString.call(e)}return!1};r.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]=r.merge.options.mergeArrays?r.merge.options.uniqueArrayItems?Array.from(new Set(e[n].concat(o[n]))):[...e[n],...o[n]]:o[n]:t(e[n])&&t(o[n])?e[n]=(0,r.merge)(e[n],o[n]):e[n]=void 0===o[n]?r.merge.options.allowUndefinedOverrides?o[n]:e[n]:o[n])})),e}),{});const o={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};r.merge.options=o,r.merge.withOptions=(e,...t)=>{r.merge.options=Object.assign(Object.assign({},o),e);const n=(0,r.merge)(...t);return r.merge.options=o,n}},121:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0});var o=t(602);class n extends Error{constructor(e,r,t){super(e),this.name="XiorError",this.request=r,this.config=r,this.response=t}}Object.defineProperty(r,"merge",{enumerable:!0,get:function(){return o.merge}}),r.XiorError=n,r.XiorTimeoutError=class extends n{constructor(e,r,t){super(e),this.name="XiorTimeoutError",this.request=r,this.config=r,this.response=t}},r.anySignal=function(e,r){let t=new globalThis.AbortController;function o(e){t.abort(e),i()}let n=[];for(let r of e){if(!0===(null==r?void 0:r.aborted)){o(r.reason);break}if(null!=(null==r?void 0:r.addEventListener)){let e=()=>{o(r.reason)};n.push((()=>{null!=(null==r?void 0:r.removeEventListener)&&r.removeEventListener("abort",e)})),r.addEventListener("abort",e)}}function i(){n.forEach((e=>{e()})),null==r||r()}let s=t.signal;return s.clear=i,s},r.buildSortedURL=function(e,r,t){let o=r?t(r):"";o&&(o=e+(e.includes("?")?"&"+o:"?"+o));let[n,i]=o.split("?");return i?`${n}?${i.split("&").sort().join("&")}`:o||e},r.delay=function(e){return new Promise((r=>{setTimeout((()=>{r("ok")}),e)}))},r.encodeParams=function e(r,t=!0,o=null){if(null==r)return"";let n=[],i=t?encodeURIComponent:e=>e;for(let s in r)if(Object.prototype.hasOwnProperty.call(r,s)){let u=r[s],c=o?`${o}[${i(s)}]`:i(s);if("object"==typeof u){let r=e(u,t,c);""!==r&&n.push(r)}else Array.isArray(u)?u.forEach(((e,r)=>{let t=`${c}[${r}]`;n.push(`${i(t)}=${i(e)}`)})):n.push(`${i(c)}=${i(u)}`)}return n.join("&")},r.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},r.isXiorError=function(e){return"XiorError"===e.name||"XiorTimeoutError"===e.name},r.joinPath=function(e,r){return r?(e.endsWith("/")?e:e+"/")+(r.startsWith("/")?r.slice(1):r):e}}},r={},function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o].call(i.exports,i,i.exports,t),i.exports}(351).default;var e,r}));

@@ -174,3 +174,3 @@ import { XiorError } from 'xior/utils';

*/
enableRetry?: boolean | ((config: XiorRequestConfig, error: XiorError) => boolean);
enableRetry?: boolean | ((config: XiorRequestConfig, error: XiorError) => boolean | undefined);
onRetry?: (config: XiorRequestConfig, error: XiorError, count: number) => void;

@@ -177,0 +177,0 @@ };

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

import{delay as t}from"xior/utils";function r(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 n(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var u=t.apply(n,e);function f(t){r(u,o,i,f,l,"next",t)}function l(t){r(u,o,i,f,l,"throw",t)}f(void 0)})}}function e(){return(e=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 o(r={}){let{retryTimes:o,retryInterval:i,enableRetry:u,onRetry:f}=e({},{retryTimes:2,retryInterval:3e3},r||{});return function(r,e){return n(function*(l){let{retryTimes:c=o,retryInterval:a=i,enableRetry:y=u,onRetry:p=f}=l,s=0;function h(){return v.apply(this,arguments)}function v(){return(v=n(function*(n=!1){if(n&&(null==e?void 0:e.REQI))for(let t of e.REQI)l=yield t(l);try{return yield r(l)}catch(i){let r="GET"===l.method||l.isGet,n=typeof y,e="undefined"===n?r:"function"===n?y(l,i):!!y;if(c===s||!e)throw i;let o="function"==typeof a?a(s):a;return o&&o>0&&s>0&&(yield t(o)),s++,p&&p(l,i,s),h(!0)}})).apply(this,arguments)}return h()})}}export{o as default};
import{delay as t}from"xior/utils";function r(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 n(t){return function(){var n=this,e=arguments;return new Promise(function(o,i){var u=t.apply(n,e);function f(t){r(u,o,i,f,l,"next",t)}function l(t){r(u,o,i,f,l,"throw",t)}f(void 0)})}}function e(){return(e=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 o(r={}){let{retryTimes:o,retryInterval:i,enableRetry:u,onRetry:f}=e({},{retryTimes:2,retryInterval:3e3},r||{});return function(r,e){return n(function*(l){let{retryTimes:c=o,retryInterval:a=i,enableRetry:y=u,onRetry:p=f}=l,s=0;function v(){return h.apply(this,arguments)}function h(){return(h=n(function*(n=!1){if(n&&(null==e?void 0:e.REQI))for(let t of e.REQI)l=yield t(l);try{return yield r(l)}catch(i){let r;let n="GET"===l.method||!!l.isGet,e=typeof y;if("function"===e&&(r=y(l,i)),void 0===r&&(r="undefined"===e?n:!!y),c===s||!r)throw i;let o="function"==typeof a?a(s):a;return o&&o>0&&s>0&&(yield t(o)),s++,p&&p(l,i,s),v(!0)}})).apply(this,arguments)}return v()})}}export{o as default};
/*! For license information please see throttle.umd.js.LICENSE.txt */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.xiorThrottle=e():t.xiorThrottle=e()}(this,(()=>{return t={272:function(t,e,r){"use strict";var s=this&&this.__awaiter||function(t,e,r,s){return new(r||(r=Promise))((function(i,n){function o(t){try{u(s.next(t))}catch(t){n(t)}}function l(t){try{u(s.throw(t))}catch(t){n(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,l)}u((s=s.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const i=r(455),n=r(121);e.default=function(t={}){const{enableThrottle:e,threshold:r=1e3,throttleCache:o=(0,i.lru)(10),onThrottle:l}=t,u=o;return function(t){const i=(e,r)=>{const i=(()=>s(this,void 0,void 0,(function*(){try{const s=yield t(r);return u.set(e,{timestamp:Date.now(),value:Promise.resolve(s)}),s}catch(t){throw"delete"in u?u.delete(e):u.del(e),t}})))();return u.set(e,{timestamp:Date.now(),value:i}),i};return o=>s(this,void 0,void 0,(function*(){const{paramsSerializer:s,threshold:a=r,enableThrottle:h=e,onThrottle:c=l}=o,f="GET"===o.method||o.isGet,p=typeof h;if("undefined"===p?f:"function"===p?h(o):Boolean(h)){const t=(0,n.buildSortedURL)(o.url&&(0,n.isAbsoluteURL)(o.url)?o.url:(0,n.joinPath)(o.baseURL||"",o.url||""),{a:o.data,b:o.params},s),e=Date.now(),r=u.get(t)||{timestamp:e},l=r.value;return l&&e-r.timestamp<=a?(null==c||c(o),l):i(t,o)}return t(o)}))}}},455:(t,e)=>{"use strict";class r{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,s=this.resetTtl){let i;if(r||this.has(t)){if(i=this.items[t],i.value=e,!1===r&&s&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const t=this.last,e=i.next,r=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,t.next=i,null!==r&&(r.next=e),null!==e&&(e.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}e.LRU=r,e.lru=function(t=1e3,e=0,s=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof s)throw new TypeError("Invalid resetTtl value");return new r(t,e,s)}},602:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.merge=void 0;const r=t=>{if("object"==typeof t&&null!==t){if("function"==typeof Object.getPrototypeOf){const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"===Object.prototype.toString.call(t)}return!1};e.merge=(...t)=>t.reduce(((t,s)=>{if(Array.isArray(s))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(s).forEach((i=>{["__proto__","constructor","prototype"].includes(i)||(Array.isArray(t[i])&&Array.isArray(s[i])?t[i]=e.merge.options.mergeArrays?e.merge.options.uniqueArrayItems?Array.from(new Set(t[i].concat(s[i]))):[...t[i],...s[i]]:s[i]:r(t[i])&&r(s[i])?t[i]=(0,e.merge)(t[i],s[i]):t[i]=void 0===s[i]?e.merge.options.allowUndefinedOverrides?s[i]:t[i]:s[i])})),t}),{});const s={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};e.merge.options=s,e.merge.withOptions=(t,...r)=>{e.merge.options=Object.assign(Object.assign({},s),t);const i=(0,e.merge)(...r);return e.merge.options=s,i}},121:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var s=r(602);class i extends Error{constructor(t,e,r){super(t),this.name="XiorError",this.request=e,this.config=e,this.response=r}}Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return s.merge}}),e.XiorError=i,e.XiorTimeoutError=class extends i{constructor(t,e,r){super(t),this.name="XiorTimeoutError",this.request=e,this.config=e,this.response=r}},e.anySignal=function(t,e){let r=new globalThis.AbortController;function s(t){r.abort(t),n()}let i=[];for(let e of t){if(!0===(null==e?void 0:e.aborted)){s(e.reason);break}if(null!=(null==e?void 0:e.addEventListener)){let t=()=>{s(e.reason)};i.push((()=>{null!=(null==e?void 0:e.removeEventListener)&&e.removeEventListener("abort",t)})),e.addEventListener("abort",t)}}function n(){i.forEach((t=>{t()})),null==e||e()}let o=r.signal;return o.clear=n,o},e.buildSortedURL=function(t,e,r){let s=e?r(e):"";s&&(s=t+(t.includes("?")?"&"+s:"?"+s));let[i,n]=s.split("?");return n?`${i}?${n.split("&").sort().join("&")}`:s||t},e.delay=function(t){return new Promise((e=>{setTimeout((()=>{e("ok")}),t)}))},e.encodeParams=function t(e,r=!0,s=null){if(null==e)return"";let i=[],n=r?encodeURIComponent:t=>t;for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let l=e[o],u=s?`${s}[${n(o)}]`:n(o);if("object"==typeof l){let e=t(l,r,u);""!==e&&i.push(e)}else Array.isArray(l)?l.forEach(((t,e)=>{let r=`${u}[${e}]`;i.push(`${n(r)}=${n(t)}`)})):i.push(`${n(u)}=${n(l)}`)}return i.join("&")},e.isAbsoluteURL=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},e.isXiorError=function(t){return"XiorError"===t.name||"XiorTimeoutError"===t.name},e.joinPath=function(t,e){return e?(t.endsWith("/")?t:t+"/")+(e.startsWith("/")?e.slice(1):e):t}}},e={},function r(s){var i=e[s];if(void 0!==i)return i.exports;var n=e[s]={exports:{}};return t[s].call(n.exports,n,n.exports,r),n.exports}(272).default;var t,e}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.xiorThrottle=e():t.xiorThrottle=e()}(this,(()=>{return t={272:function(t,e,r){"use strict";var s=this&&this.__awaiter||function(t,e,r,s){return new(r||(r=Promise))((function(i,n){function o(t){try{u(s.next(t))}catch(t){n(t)}}function l(t){try{u(s.throw(t))}catch(t){n(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,l)}u((s=s.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const i=r(455),n=r(121);e.default=function(t={}){const{enableThrottle:e,threshold:r=1e3,throttleCache:o=(0,i.lru)(10),onThrottle:l}=t,u=o;return function(t){const i=(e,r)=>{const i=(()=>s(this,void 0,void 0,(function*(){try{const s=yield t(r);return u.set(e,{timestamp:Date.now(),value:Promise.resolve(s)}),s}catch(t){throw"delete"in u?u.delete(e):u.del(e),t}})))();return u.set(e,{timestamp:Date.now(),value:i}),i};return o=>s(this,void 0,void 0,(function*(){const{paramsSerializer:s,threshold:a=r,enableThrottle:h=e,onThrottle:c=l}=o,f="GET"===o.method||o.isGet,p=typeof h;let d;if("function"===p&&(d=h(o)),void 0===d&&(d="undefined"===p?f:Boolean(h)),d){const t=(0,n.buildSortedURL)(o.url&&(0,n.isAbsoluteURL)(o.url)?o.url:(0,n.joinPath)(o.baseURL||"",o.url||""),{a:o.data,b:o.params},s),e=Date.now(),r=u.get(t)||{timestamp:e},l=r.value;return l&&e-r.timestamp<=a?(null==c||c(o),l):i(t,o)}return t(o)}))}}},455:(t,e)=>{"use strict";class r{constructor(t=0,e=0,r=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=r,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map((t=>[t,this.get(t)]))}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0==--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){let e;if(this.has(t)){const r=this.items[t];this.ttl>0&&r.expiry<=Date.now()?this.delete(t):(e=r.value,this.set(t,e,!0))}return e}has(t){return t in this.items}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}set(t,e,r=!1,s=this.resetTtl){let i;if(r||this.has(t)){if(i=this.items[t],i.value=e,!1===r&&s&&(i.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.last!==i){const t=this.last,e=i.next,r=i.prev;this.first===i&&(this.first=i.next),i.next=null,i.prev=this.last,t.next=i,null!==r&&(r.next=e),null!==e&&(e.prev=r)}}else this.max>0&&this.size===this.max&&this.evict(!0),i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1==++this.size?this.first=i:this.last.next=i;return this.last=i,this}values(t=this.keys()){return t.map((t=>this.get(t)))}}e.LRU=r,e.lru=function(t=1e3,e=0,s=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof s)throw new TypeError("Invalid resetTtl value");return new r(t,e,s)}},602:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.merge=void 0;const r=t=>{if("object"==typeof t&&null!==t){if("function"==typeof Object.getPrototypeOf){const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}return"[object Object]"===Object.prototype.toString.call(t)}return!1};e.merge=(...t)=>t.reduce(((t,s)=>{if(Array.isArray(s))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return Object.keys(s).forEach((i=>{["__proto__","constructor","prototype"].includes(i)||(Array.isArray(t[i])&&Array.isArray(s[i])?t[i]=e.merge.options.mergeArrays?e.merge.options.uniqueArrayItems?Array.from(new Set(t[i].concat(s[i]))):[...t[i],...s[i]]:s[i]:r(t[i])&&r(s[i])?t[i]=(0,e.merge)(t[i],s[i]):t[i]=void 0===s[i]?e.merge.options.allowUndefinedOverrides?s[i]:t[i]:s[i])})),t}),{});const s={allowUndefinedOverrides:!0,mergeArrays:!0,uniqueArrayItems:!0};e.merge.options=s,e.merge.withOptions=(t,...r)=>{e.merge.options=Object.assign(Object.assign({},s),t);const i=(0,e.merge)(...r);return e.merge.options=s,i}},121:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});var s=r(602);class i extends Error{constructor(t,e,r){super(t),this.name="XiorError",this.request=e,this.config=e,this.response=r}}Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return s.merge}}),e.XiorError=i,e.XiorTimeoutError=class extends i{constructor(t,e,r){super(t),this.name="XiorTimeoutError",this.request=e,this.config=e,this.response=r}},e.anySignal=function(t,e){let r=new globalThis.AbortController;function s(t){r.abort(t),n()}let i=[];for(let e of t){if(!0===(null==e?void 0:e.aborted)){s(e.reason);break}if(null!=(null==e?void 0:e.addEventListener)){let t=()=>{s(e.reason)};i.push((()=>{null!=(null==e?void 0:e.removeEventListener)&&e.removeEventListener("abort",t)})),e.addEventListener("abort",t)}}function n(){i.forEach((t=>{t()})),null==e||e()}let o=r.signal;return o.clear=n,o},e.buildSortedURL=function(t,e,r){let s=e?r(e):"";s&&(s=t+(t.includes("?")?"&"+s:"?"+s));let[i,n]=s.split("?");return n?`${i}?${n.split("&").sort().join("&")}`:s||t},e.delay=function(t){return new Promise((e=>{setTimeout((()=>{e("ok")}),t)}))},e.encodeParams=function t(e,r=!0,s=null){if(null==e)return"";let i=[],n=r?encodeURIComponent:t=>t;for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let l=e[o],u=s?`${s}[${n(o)}]`:n(o);if("object"==typeof l){let e=t(l,r,u);""!==e&&i.push(e)}else Array.isArray(l)?l.forEach(((t,e)=>{let r=`${u}[${e}]`;i.push(`${n(r)}=${n(t)}`)})):i.push(`${n(u)}=${n(l)}`)}return i.join("&")},e.isAbsoluteURL=function(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)},e.isXiorError=function(t){return"XiorError"===t.name||"XiorTimeoutError"===t.name},e.joinPath=function(t,e){return e?(t.endsWith("/")?t:t+"/")+(e.startsWith("/")?e.slice(1):e):t}}},e={},function r(s){var i=e[s];if(void 0!==i)return i.exports;var n=e[s]={exports:{}};return t[s].call(n.exports,n,n.exports,r),n.exports}(272).default;var t,e}));

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

import{lru as t}from"tiny-lru";import{buildSortedURL as e,isAbsoluteURL as r,joinPath as n}from"xior/utils";function o(t,e,r,n,o,u,i){try{var l=t[u](i),a=l.value}catch(t){r(t);return}l.done?e(a):Promise.resolve(a).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise(function(n,u){var i=t.apply(e,r);function l(t){o(i,n,u,l,a,"next",t)}function a(t){o(i,n,u,l,a,"throw",t)}l(void 0)})}}function i(o={}){let{enableThrottle:i,threshold:l=1e3,throttleCache:a=t(10),onThrottle:s}=o;return function(t){let o=(e,r)=>{let n=u(function*(){try{let n=yield t(r);return a.set(e,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(t){throw"delete"in a?a.delete(e):a.del(e),t}})();return a.set(e,{timestamp:Date.now(),value:n}),n};return u(function*(u){let{paramsSerializer:f,threshold:m=l,enableThrottle:c=i,onThrottle:d=s}=u,h="GET"===u.method||u.isGet,p=typeof c;if("undefined"===p?h:"function"===p?c(u):!!c){let t=e(u.url&&r(u.url)?u.url:n(u.baseURL||"",u.url||""),{a:u.data,b:u.params},f),i=Date.now(),l=a.get(t)||{timestamp:i},s=l.value;return s&&i-l.timestamp<=m?(null==d||d(u),s):o(t,u)}return t(u)})}}export{i as default};
import{lru as t}from"tiny-lru";import{buildSortedURL as e,isAbsoluteURL as r,joinPath as n}from"xior/utils";function o(t,e,r,n,o,u,i){try{var l=t[u](i),a=l.value}catch(t){r(t);return}l.done?e(a):Promise.resolve(a).then(n,o)}function u(t){return function(){var e=this,r=arguments;return new Promise(function(n,u){var i=t.apply(e,r);function l(t){o(i,n,u,l,a,"next",t)}function a(t){o(i,n,u,l,a,"throw",t)}l(void 0)})}}function i(o={}){let{enableThrottle:i,threshold:l=1e3,throttleCache:a=t(10),onThrottle:s}=o;return function(t){let o=(e,r)=>{let n=u(function*(){try{let n=yield t(r);return a.set(e,{timestamp:Date.now(),value:Promise.resolve(n)}),n}catch(t){throw"delete"in a?a.delete(e):a.del(e),t}})();return a.set(e,{timestamp:Date.now(),value:n}),n};return u(function*(u){let f;let{paramsSerializer:m,threshold:c=l,enableThrottle:d=i,onThrottle:h=s}=u,p="GET"===u.method||u.isGet,v=typeof d;if("function"===v&&(f=d(u)),void 0===f&&(f="undefined"===v?p:!!d),f){let t=e(u.url&&r(u.url)?u.url:n(u.baseURL||"",u.url||""),{a:u.data,b:u.params},m),i=Date.now(),l=a.get(t)||{timestamp:i},s=l.value;return s&&i-l.timestamp<=c?(null==h||h(u),s):o(t,u)}return t(u)})}}export{i as default};

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

- [1. Is **xior** 100% compatiable with `axios`?](#1-is-xior-100-compatiable-with-axios)
- [2. Can I use xior in projects like Bun, Expo, React Native, Next.js, Vue, or Nuxt.js?](#2-can-i-use-xior-in-projects-like-bun-expo-react-native-nextjs-vue-or-nuxtjs)
- [2. Can I use xior in projects like Bun, Expo, React Native, RemixJS, Next.js, Vue, or Nuxt.js?](#2-can-i-use-xior-in-projects-like-bun-expo-react-native-remixjs-nextjs-vue-or-nuxtjs)
- [3. How do I handle responses with types like `'stream'`, `'document'`, `'arraybuffer'`, or `'blob'`?](#3-how-do-i-handle-responses-with-types-like-stream-document-arraybuffer-or-blob)

@@ -73,2 +73,3 @@ - [5. How do I support older browsers?](#5-how-do-i-support-older-browsers)

- [Processing a text file line by line](#processing-a-text-file-line-by-line)
- [Star History](#star-history)
- [Thanks](#thanks)

@@ -122,3 +123,3 @@

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

@@ -138,3 +139,3 @@ <!-- Usage -->

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

@@ -453,3 +454,3 @@ <!-- Usage -->

retryInterval?: number | ((errorCount: number) => number);
enableRetry?: boolean | (config: XiorRequestConfig, error: XiorError | Error) => boolean;
enableRetry?: boolean | (config: XiorRequestConfig, error: XiorError | Error) => boolean | undefined;
onRetry?: (config: XiorRequestConfig, error: XiorError | Error, count: number) => void;

@@ -461,8 +462,8 @@ }): XiorPlugin;

| Param | Type | Default value | Description |
| ------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| retryTimes | number | 2 | Set the retry times for failed request |
| retryInterval | number \| ((errorCount: number) => number) | 3000 | After first time retry, the next retries interval time, default interval is 3 seconds; you can use function as param too |
| enableRetry | boolean \| ((config: XiorRequestConfig, error: XiorError \| Error) => boolean) | (config, error) => config.method === 'GET' \|\| config.isGet | Default only retry if `GET` request error and `retryTimes > 0` |
| onRetry | boolean \| ((config: XiorRequestConfig, error: XiorError \| Error, count: number) => void) | undefined | For log retry info |
| Param | Type | Default value | Description |
| ------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |
| retryTimes | number | 2 | Set the retry times for failed request |
| retryInterval | number \| ((errorCount: number) => number) | 3000 | After first time retry, the next retries interval time, default interval is 3 seconds; you can use function as param too |
| enableRetry | boolean \| ((config: XiorRequestConfig, error: XiorError \| Error) => boolean \| undefined) | (config, error) => config.method === 'GET' \|\| config.isGet | Default only retry if `GET` request error and `retryTimes > 0` |
| onRetry | boolean \| ((config: XiorRequestConfig, error: XiorError \| Error, count: number) => void) | undefined | For log retry info |

@@ -481,3 +482,3 @@ Basic usage:

retryInterval(count) {
return count * 3000;
return count * 1e3;
},

@@ -487,2 +488,8 @@ onRetry(config, error, count) {

},
// enableRetry(config, error) {
// if (error.response?.status === 401) {
// return false;
// }
// // no return or return `undefined` here, will reuse the default `enableRetry` logic
// },
})

@@ -504,2 +511,19 @@ );

Advance usage:
> The retry key for the unique request generated by use `params` and `data`, if your request depends on `headers`, you can add request interceptor to add headers's value to `params`:
```ts
import xior from 'xior';
import errorRetryPlugin from 'xior/plugins/error-retry';
const http = xior.create();
http.plugins.use(errorRetryPlugin());
http.interceptors.request.use((config) => {
config.params['___k'] = `${config.headers['x-custom-field'] || ''}`;
return config;
});
```
Use CDN:

@@ -510,5 +534,5 @@

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.7/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.8/dist/xior.umd.js"></script>
<!-- Load plugin -->
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.7/plugins/error-retry.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.8/plugins/error-retry.umd.js"></script>

@@ -526,6 +550,6 @@ <!-- Usage -->

```html
<script src="https://unpkg.com/xior@0.3.7/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/dist/xior.umd.js"></script>
<!-- Load plugin -->
<script src="https://unpkg.com/xior@0.3.7/plugins/error-retry.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/plugins/error-retry.umd.js"></script>

@@ -553,3 +577,3 @@ <!-- Usage -->

*/
enableThrottle?: boolean | ((config?: XiorRequestConfig) => boolean);
enableThrottle?: boolean | ((config?: XiorRequestConfig) => boolean | undefined);
throttleCache?: ICacheLike<RecordedCache>;

@@ -564,7 +588,7 @@ onThrottle?: (config: XiorRequestConfig) => void;

| Param | Type | Default value | Description |
| -------------- | -------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| threshold | number | 1000 | The number of milliseconds to throttle request invocations to |
| enableThrottle | boolean \| ((config: Xiorconfig) => boolean) | (config) => config.method === 'GET' \|\| config.isGet | Default only enabled in `GET` request |
| throttleCache | CacheLike | lru(10) | CacheLike instance that will be used for storing throttled requests, use `tiny-lru` module |
| Param | Type | Default value | Description |
| -------------- | ---------------------------------------------------------------- | ----------------------------------------------------- | ------------------------------------------------------------------------------------------ |
| threshold | number | 1000 | The number of milliseconds to throttle request invocations to |
| enableThrottle | boolean \| ((config: XiorRequestConfig) => boolean \| undefined) | (config) => config.method === 'GET' \|\| config.isGet | Default only enabled in `GET` request |
| throttleCache | CacheLike | lru(10) | CacheLike instance that will be used for storing throttled requests, use `tiny-lru` module |

@@ -622,5 +646,5 @@ Basic usage:

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

@@ -638,6 +662,6 @@ <!-- Usage -->

```html
<script src="https://unpkg.com/xior@0.3.7/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/dist/xior.umd.js"></script>
<!-- Load plugin -->
<script src="https://unpkg.com/xior@0.3.7/plugins/throttle.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/plugins/throttle.umd.js"></script>

@@ -697,5 +721,5 @@ <!-- Usage -->

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

@@ -713,6 +737,6 @@ <!-- Usage -->

```html
<script src="https://unpkg.com/xior@0.3.7/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/dist/xior.umd.js"></script>
<!-- Load plugin -->
<script src="https://unpkg.com/xior@0.3.7/plugins/dedupe.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/plugins/dedupe.umd.js"></script>

@@ -735,3 +759,3 @@ <!-- Usage -->

function errorCachePlugin(options: {
enableCache?: boolean | ((config?: XiorRequestConfig) => boolean);
enableCache?: boolean | ((config?: XiorRequestConfig) => boolean | undefined);
defaultCache?: ICacheLike<XiorPromise>;

@@ -744,7 +768,7 @@ useCacheFirst?: boolean;

| Param | Type | Default value | Description |
| ------------- | -------------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| enableCache | boolean \| ((config: Xiorconfig) => boolean) | (config) => config.method === 'GET' \|\| config.isGet | Default only enabled in `GET` request |
| defaultCache | CacheLike | lru(Inifinite, 0) | will used for storing requests by default, except you define a custom Cache with your request config, use `tiny-lru` module |
| useCacheFirst | boolean | false | If `useCacheFirst: true` and there's a cache, it will return the cached response first, then run fetching in the background. This is useful when the response takes a long time, and the data is unnecessary in real-time. |
| Param | Type | Default value | Description |
| ------------- | ---------------------------------------------------------------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| enableCache | boolean \| ((config: XiorRequestConfig) => boolean \| undefined) | (config) => config.method === 'GET' \|\| config.isGet | Default only enabled in `GET` request |
| defaultCache | CacheLike | lru(Inifinite, 0) | will used for storing requests by default, except you define a custom Cache with your request config, use `tiny-lru` module |
| useCacheFirst | boolean | false | If `useCacheFirst: true` and there's a cache, it will return the cached response first, then run fetching in the background. This is useful when the response takes a long time, and the data is unnecessary in real-time. |

@@ -779,5 +803,5 @@ Basic usage:

```html
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.7/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.8/dist/xior.umd.js"></script>
<!-- Load plugin -->
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.7/plugins/error-cache.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.8/plugins/error-cache.umd.js"></script>

@@ -795,6 +819,6 @@ <!-- Usage -->

```html
<script src="https://unpkg.com/xior@0.3.7/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/dist/xior.umd.js"></script>
<!-- Load plugin -->
<script src="https://unpkg.com/xior@0.3.7/plugins/error-cache.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/plugins/error-cache.umd.js"></script>

@@ -828,6 +852,6 @@ <!-- Usage -->

| Param | Type | Default value | Description |
| ------------ | -------------------------------------------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| enableCache | boolean \| ((config: Xiorconfig) => boolean) | (config) => config.method === 'GET' \|\| config.isGet | Default only enabled in `GET` request |
| defaultCache | CacheLike | lru(100, 1000\*60\*5) | will used for storing requests by default, except you define a custom Cache with your request config, use `tiny-lru` module |
| Param | Type | Default value | Description |
| ------------ | ---------------------------------------------------------------- | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| enableCache | boolean \| ((config: XiorRequestConfig) => boolean \| undefined) | (config) => config.method === 'GET' \|\| config.isGet | Default only enabled in `GET` request |
| defaultCache | CacheLike | lru(100, 1000\*60\*5) | will used for storing requests by default, except you define a custom Cache with your request config, use `tiny-lru` module |

@@ -935,5 +959,5 @@ Basic usage:

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

@@ -951,6 +975,6 @@ <!-- Usage -->

```html
<script src="https://unpkg.com/xior@0.3.7/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/dist/xior.umd.js"></script>
<!-- Load plugin -->
<script src="https://unpkg.com/xior@0.3.7/plugins/progress.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/plugins/progress.umd.js"></script>

@@ -1062,5 +1086,5 @@ <!-- Usage -->

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

@@ -1078,6 +1102,6 @@ <!-- Usage -->

```html
<script src="https://unpkg.com/xior@0.3.7/dist/xior.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/dist/xior.umd.js"></script>
<!-- Load plugin -->
<script src="https://unpkg.com/xior@0.3.7/plugins/mock.umd.js"></script>
<script src="https://unpkg.com/xior@0.3.8/plugins/mock.umd.js"></script>

@@ -1143,3 +1167,3 @@ <!-- Usage -->

### 2. Can I use xior in projects like Bun, Expo, React Native, Next.js, Vue, or Nuxt.js?
### 2. Can I use xior in projects like Bun, Expo, React Native, RemixJS, Next.js, Vue, or Nuxt.js?

@@ -1796,2 +1820,6 @@ **Yes**, **xior** works anywhere where the native `fetch` API is supported.

## Star History
[![Star History Chart](https://api.star-history.com/svg?repos=suhaotian/xior&type=Date)](https://star-history.com/#suhaotian/xior&Date)
## Thanks

@@ -1798,0 +1826,0 @@

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