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

xior

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xior - npm Package Compare versions

Comparing version 0.3.11 to 0.3.12

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,h;let d=yield function(e){return f.apply(this,arguments)}(e),{url:p,method:E,headers:m,timeout:R,signal:O,data:g,_data:P,_url:I,isGet:S}=d,j=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}(d,["url","method","headers","timeout","signal","data","_data","_url","isGet"]);e._url=I;let w=[];if(R&&v){let t=new AbortController;h=setTimeout(()=>{t.abort(new r(`timeout of ${R}ms exceeded`,e))},R),w.push(t.signal)}O&&w.push(O),l=w[0],w.length>1&&(l=n(w,()=>{clearTimeout(h)}));let T=I||p||"";e.baseURL&&!i(T)&&(T=s(e.baseURL,T));try{c=yield fetch(T,y({body:S?void 0:P},j,{signal:l,method:E,headers:m}))}catch(e){for(let r of t.RESI)r.onRejected&&(yield r.onRejected(e));throw e}finally{h&&clearTimeout(h),null==l||null==(a=l.clear)||a.call(l)}let b={response:c,config:e,status:c.status,statusText:c.statusText,headers:c.headers};if(!c.ok){let r;try{(r=yield c.text())&&(r=JSON.parse(r))}catch(e){}let n=new o(c.status?`Request failed with status code ${c.status}`:"Network error",e,y({data:r},b));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"===E)return y({data:void 0,request:e},b);let{responseType:x}=e;if(!x||["json","text"].includes(x)){let r;try{(r=yield c.text())&&"text"!==x&&(r=JSON.parse(r))}catch(e){}let n={data:r,config:e,request:e,response:c};for(let e of t.RESI)n=yield e.fn(n);return y({data:n.data,request:e},b)}return y({data:void 0,request:e},b)})()}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.11";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,h;let d=yield function(e){return f.apply(this,arguments)}(e),{url:p,method:E,headers:m,timeout:R,signal:O,data:g,_data:P,_url:I,isGet:S}=d,j=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}(d,["url","method","headers","timeout","signal","data","_data","_url","isGet"]);e._url=I;let w=[];if(R&&v){let t=new AbortController;h=setTimeout(()=>{t.abort(new r(`timeout of ${R}ms exceeded`,e))},R),w.push(t.signal)}O&&w.push(O),l=w[0],w.length>1&&(l=n(w,()=>{clearTimeout(h)}));let T=I||p||"";e.baseURL&&!i(T)&&(T=s(e.baseURL,T));try{c=yield fetch(T,y({body:S?void 0:P},j,{signal:l,method:E,headers:m}))}catch(e){for(let r of t.RESI)r.onRejected&&(yield r.onRejected(e));throw e}finally{h&&clearTimeout(h),null==l||null==(a=l.clear)||a.call(l)}let b={response:c,config:e,status:c.status,statusText:c.statusText,headers:c.headers};if(!c.ok){let r;try{(r=yield c.text())&&(r=JSON.parse(r))}catch(e){}let n=new o(c.status?`Request failed with status code ${c.status}`:"Network error",e,y({data:r},b));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"===E)return y({data:void 0,request:e},b);let{responseType:x}=e;if(!x||["json","text"].includes(x)){let r;try{(r=yield c.text())&&"text"!==x&&(r=JSON.parse(r))}catch(e){}let n={data:r,config:e,request:e,response:c};for(let e of t.RESI)n=yield e.fn(n);return y({data:n.data,request:e},b)}return y({data:void 0,request:e},b)})()}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.12";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{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((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 c(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}t.likeGET=c,t.default=function(e){return o(this,void 0,void 0,(function*(){const t=e.paramsSerializer||n.encodeParams,r=!1!==e.encodeURI,o=e.method?e.method.toUpperCase():"GET";let s=e.url||"";const u=s,l=e.data;let d=l;const f=(null==e?void 0:e.headers)||{};let h=e.params||{};const p=c(o);if(l&&!(l instanceof FormData)){let r="";if(null==e?void 0:e.headers){const t=Object.keys(e.headers).find((e=>"content-type"===e.toLowerCase()));t&&(r=e.headers[t],e.headers["Content-Type"]=r,"Content-Type"!==t&&delete e.headers[t])}r||(r=p?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:u,_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{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))},n=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r},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)),c="undefined"!=typeof AbortController;class u{static create(e){return new u(e)}constructor(e){this.REQI=[],this.RESI=[],this.P=[],this.config=e,this.defaults={params:{},headers:{}}}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter((t=>t!==e))},clear:()=>{this.REQI=[]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter((t=>t.fn!==e))},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this.P.push(e),e),eject:e=>{this.P=this.P.filter((t=>t!==e))},clear:()=>{this.P=[]}}}request(e){return o(this,void 0,void 0,(function*(){let t=(0,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:u,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 j;if(d&&c){const t=new AbortController;j=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(j)})));let v,E=y||s||"";e.baseURL&&!(0,i.isAbsoluteURL)(E)&&(E=(0,i.joinPath)(e.baseURL,E));try{v=yield fetch(E,Object.assign(Object.assign({body:m?void 0:p},b),{signal:g,method:u,headers:l}))}catch(e){for(const t of this.RESI)t.onRejected&&(yield t.onRejected(e));throw e}finally{j&&clearTimeout(j),null===(t=null==g?void 0:g.clear)||void 0===t||t.call(g)}const P={response:v,config:e,status:v.status,statusText:v.statusText,headers:v.headers};if(!v.ok){let t;try{t=yield v.text(),t&&(t=JSON.parse(t))}catch(e){}const o=new i.XiorError(v.status?`Request failed with status code ${v.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"===u)return Object.assign({data:void 0,request:e},P);const{responseType:_}=e;if(!_||["json","text"].includes(_)){let t;try{t=yield v.text(),t&&"text"!==_&&(t=JSON.parse(t))}catch(e){}let r={data:t,config:e,request:e,response:v};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=u,u.VERSION="0.3.11"},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);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],c=o?`${o}[${s(i)}]`:s(i);if("object"==typeof a){let t=e(a,r,c);""!==t&&n.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{let r=`${c}[${t}]`;n.push(`${s(r)}=${s(e)}`)})):n.push(`${s(c)}=${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{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((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 c(e="GET"){return["HEAD","GET","OPTIONS"].includes(e)}t.likeGET=c,t.default=function(e){return o(this,void 0,void 0,(function*(){const t=e.paramsSerializer||n.encodeParams,r=!1!==e.encodeURI,o=e.method?e.method.toUpperCase():"GET";let s=e.url||"";const u=s,l=e.data;let d=l;const f=(null==e?void 0:e.headers)||{};let h=e.params||{};const p=c(o);if(l&&!(l instanceof FormData)){let r="";if(null==e?void 0:e.headers){const t=Object.keys(e.headers).find((e=>"content-type"===e.toLowerCase()));t&&(r=e.headers[t],e.headers["Content-Type"]=r,"Content-Type"!==t&&delete e.headers[t])}r||(r=p?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:u,_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{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))},n=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r},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)),c="undefined"!=typeof AbortController;class u{static create(e){return new u(e)}constructor(e){this.REQI=[],this.RESI=[],this.P=[],this.config=e,this.defaults={params:{},headers:{}}}get interceptors(){return{request:{use:(e,t)=>(this.REQI.push(e),e),eject:e=>{this.REQI=this.REQI.filter((t=>t!==e))},clear:()=>{this.REQI=[]}},response:{use:(e,t)=>(this.RESI.push({fn:e,onRejected:t}),e),eject:e=>{this.RESI=this.RESI.filter((t=>t.fn!==e))},clear:()=>{this.RESI=[]}}}}get plugins(){return{use:e=>(this.P.push(e),e),eject:e=>{this.P=this.P.filter((t=>t!==e))},clear:()=>{this.P=[]}}}request(e){return o(this,void 0,void 0,(function*(){let t=(0,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:u,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 j;if(d&&c){const t=new AbortController;j=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(j)})));let v,E=y||s||"";e.baseURL&&!(0,i.isAbsoluteURL)(E)&&(E=(0,i.joinPath)(e.baseURL,E));try{v=yield fetch(E,Object.assign(Object.assign({body:m?void 0:p},b),{signal:g,method:u,headers:l}))}catch(e){for(const t of this.RESI)t.onRejected&&(yield t.onRejected(e));throw e}finally{j&&clearTimeout(j),null===(t=null==g?void 0:g.clear)||void 0===t||t.call(g)}const P={response:v,config:e,status:v.status,statusText:v.statusText,headers:v.headers};if(!v.ok){let t;try{t=yield v.text(),t&&(t=JSON.parse(t))}catch(e){}const o=new i.XiorError(v.status?`Request failed with status code ${v.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"===u)return Object.assign({data:void 0,request:e},P);const{responseType:_}=e;if(!_||["json","text"].includes(_)){let t;try{t=yield v.text(),t&&"text"!==_&&(t=JSON.parse(t))}catch(e){}let r={data:t,config:e,request:e,response:v};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=u,u.VERSION="0.3.12"},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);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],c=o?`${o}[${s(i)}]`:s(i);if("object"==typeof a){let t=e(a,r,c);""!==t&&n.push(t)}else Array.isArray(a)?a.forEach(((e,t)=>{let r=`${c}[${t}]`;n.push(`${s(r)}=${s(e)}`)})):n.push(`${s(c)}=${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.11/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.11/plugins/mock.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.12/dist/xior.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/xior@0.3.12/plugins/mock.umd.js"></script>

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

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

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

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

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

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

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

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

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

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

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

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

// enableRetry(config, error) {
// if (error.response?.status === 401) {
// if ([401, 400].includes(error.response?.status)) { // no retry when status is 400 or 401
// return false;

@@ -534,5 +534,5 @@ // }

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

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

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

@@ -645,5 +645,5 @@ <!-- Usage -->

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

@@ -661,6 +661,6 @@ <!-- Usage -->

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

@@ -720,5 +720,5 @@ <!-- Usage -->

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

@@ -736,6 +736,6 @@ <!-- Usage -->

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

@@ -801,5 +801,5 @@ <!-- Usage -->

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

@@ -817,6 +817,6 @@ <!-- Usage -->

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

@@ -956,5 +956,5 @@ <!-- Usage -->

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

@@ -972,6 +972,6 @@ <!-- Usage -->

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

@@ -1083,5 +1083,5 @@ <!-- Usage -->

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

@@ -1099,6 +1099,6 @@ <!-- Usage -->

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

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

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