xior
Version:
A lite http request lib based on fetch with plugins support and similar API to axios.
1 lines • 4.64 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.xiorUtils=t():e.xiorUtils=t()}(this,(function(){return function(){"use strict";var e={99:function(e,t,r){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.buildSortedURL=void 0,t.delay=function(e){return new Promise((t=>{setTimeout((()=>{t(1)}),e)}))};const n=o(r(629));t.buildSortedURL=n.default},330:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.DELETE=t.PATCH=t.PUT=t.POST=t.OPTIONS=t.GET=t.HEAD=t.m=t.isArray=t.keys=t.op=t.nullValue=t.undefinedValue=t.O=t.h=t.status=t.addEventListener=t.qs=t.abort=t.json=t.text=t.p=t.f=t.o=void 0,t.o="object",t.f="function",t.p="prototype",t.text="text",t.json="json",t.abort="abort",t.qs="paramsSerializer",t.addEventListener="addEventListener",t.status="status",t.h="headers",t.O=Object,t.undefinedValue=void 0,t.nullValue=null,t.op=t.O[t.p],t.keys=t.O.keys,t.isArray=Array.isArray,t.m="method",t.HEAD="HEAD",t.GET="GET",t.OPTIONS="OPTIONS",t.POST="POST",t.PUT="PUT",t.PATCH="PATCH",t.DELETE="DELETE"},629:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r){const o=t?r(t):"",n=e.includes("?")?"&":"?",i=o?`${e}${n}${o}`:e,[s,u]=i.split("?");if(!u)return i;return`${s}?${u.split("&").sort().join("&")}`}},699:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.anySignal=function(e,t){const r=new AbortController;function n(e){r.abort(e),s()}const i=[];for(const t of e){if(!0===(null==t?void 0:t.aborted)){n(t.reason);break}if(null==t?void 0:t[o.addEventListener]){const e=()=>{n(t.reason)};i.push((()=>{var r;null===(r=t.removeEventListener)||void 0===r||r.call(t,o.abort,e)})),t[o.addEventListener](o.abort,e)}}function s(){i.forEach((e=>e())),null==t||t()}const u=r.signal;return u.clear=s,u};const o=r(330)},729:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;const o=r(330),n=o.O.getPrototypeOf,i=e=>{if(e!==o.nullValue&&typeof e===o.o){if(typeof n===o.f){const t=n(e);return t===o.op||t===o.nullValue}return o.op.toString.call(e)===`[${o.o} Object]`}return!1};t.merge=(...e)=>e.reduce(((e,r)=>{if((0,o.isArray)(r))throw new TypeError(`Arguments must be ${o.o}s, not arrays.`);return(0,o.keys)(r).forEach((n=>{["__proto__","constructor",o.p].includes(n)||((0,o.isArray)(e[n])&&(0,o.isArray)(r[n])?e[n]=Array.from(new Set(e[n].concat(r[n]))):i(e[n])&&i(r[n])?e[n]=(0,t.merge)(e[n],r[n]):e[n]=r[n])})),e}),{})},976:function(e,t,r){var o=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),n=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||o(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.XiorTimeoutError=t.XiorError=void 0,t.encodeParams=function e(t,r=!0,o=i.nullValue,n){if(t===i.undefinedValue||t===i.nullValue)return"";const s=[],u=r?encodeURIComponent:e=>e,a=(0,i.isArray)(t),{arrayFormat:l,allowDots:c,serializeDate:f}=n||{},d=e=>{if(c&&!a)return`.${e}`;if(a){if("brackets"===l)return"[]";if("repeat"===l)return""}return`[${e}]`};for(const a in t)if(i.op.hasOwnProperty.call(t,a)){let l=t[a];if(l!==i.undefinedValue){const t=o?`${o}${d(a)}`:u(a);if(!isNaN(l)&&l instanceof Date&&(l=f?f(l):l.toISOString()),typeof l===i.o){const o=e(l,r,t,n);""!==o&&s.push(o)}else s.push(`${u(t)}=${u(l)}`)}}return s.join("&")},t.trimUndefined=function e(t){return(0,i.isArray)(t)?t.map(e):(t&&typeof t===i.o&&(0,i.keys)(t).forEach((r=>{const o=t[r];o===i.undefinedValue?delete t[r]:e(o)})),t)},t.isAbsoluteURL=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},t.joinPath=function(e,t){return e?t?(e.endsWith("/")?e:e+"/")+("/"===t[0]?t.slice(1):t):e:t||""},t.isXiorError=function(e){return(null==e?void 0:e.name)===s||(null==e?void 0:e.name)===u};const i=r(330);n(r(699),t),n(r(729),t),n(r(99),t);const s="XiorError",u="XiorTimeoutError";class a extends Error{constructor(e,t,r){super(e),this.name=s,this.request=t,this.config=t,this.response=r}}t.XiorError=a,t.XiorTimeoutError=class extends a{constructor(e,t,r){super(e,t,r),this.name=u}}}},t={},r=function r(o){var n=t[o];if(void 0!==n)return n.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,r),i.exports}(976);return r.default}()}));