UNPKG

wretch

Version:

A tiny wrapper built around fetch with an intuitive syntax.

3 lines (2 loc) 754 B
var global,factory;global=this,factory=function(){return()=>{let e=null,r=null;return{beforeRequest(o,t){r=o._config.polyfill("AbortController",0,1),!t.signal&&r&&(t.signal=r.signal),e={ref:null,clear(){e.ref&&(clearTimeout(e.ref),e.ref=null)}}},wretch:{signal(e){return{...this,_options:{...this._options,signal:e.signal}}}},resolver:{setTimeout(o,t=r){return e.clear(),e.ref=setTimeout((()=>t.abort()),o),this},controller(){return[r,this]},onAbort(e){return this.error("AbortError",e)}}}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):(global="undefined"!=typeof globalThis?globalThis:global||self).wretchAbortAddon=factory(); //# sourceMappingURL=abort.min.js.map