xior
Version:
A lite http request lib based on fetch with plugins support and similar API to axios.
2 lines (1 loc) • 1.17 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});var _chunk646GK2HSjs = require('../chunk-646GK2HS.js');var _chunkPXDN3KFOjs = require('../chunk-PXDN3KFO.js');function x(I={}){let{retryTimes:h,retryInterval:q,enableRetry:C,onRetry:g}=_chunkPXDN3KFOjs.a.call(void 0, {retryTimes:2,retryInterval:3e3},I);return function(T,o){return r=>_chunkPXDN3KFOjs.d.call(void 0, this,null,function*(){let{retryTimes:v=h,retryInterval:a=q,enableRetry:l=C,onRetry:d=g}=r,u=0;function m(w=!1){return _chunkPXDN3KFOjs.d.call(void 0, this,null,function*(){var E;if(w&&(o!=null&&o.REQI))for(let e of o.REQI)r=yield e(r);try{let e=T(r),i=0,t=[];for((E=o==null?void 0:o.RESI)==null||E.forEach(function(n){t.push(n.fn,n.onRejected)});t.length>i;)e=e.then(t[i++],t[i++]);return r._did=!0,yield e}catch(e){let i=r.method===_chunk646GK2HSjs.n||!!r.isGet,t=typeof l,y=t===_chunk646GK2HSjs.b,n=_chunk646GK2HSjs.i;if(y&&(n=l(r,e)),n===_chunk646GK2HSjs.i&&(n=y||t===`${_chunk646GK2HSjs.i}`?i:!!l),u>=v||!n)throw e;u++;let f=typeof a===_chunk646GK2HSjs.b?a(u,r,e):a;return f&&f>0&&(yield _chunk646GK2HSjs.w.call(void 0, f)),d&&d(r,e,u),m(!0)}})}return m()})}}exports.default = x;