UNPKG

qoopido.nucleus

Version:

Lightweight, atomic and modular JavaScript utility library that strongly encourages the creation and usage of small yet flexible, reusable and easily maintainable modules.

4 lines (3 loc) 2.15 kB
/**! Qoopido.nucleus 3.2.15 | http://nucleus.qoopido.com | (c) 2021 Dirk Lueth */ !function(e,t){"use strict";provide(["/demand/weakmap","/demand/pledge","/demand/validator/isObject","/demand/function/iterate","../url","../function/merge"],(function(n,r,a,s,i,u){var o="XDomainRequest"in e&&e.XDomainRequest||t,c=new n;function d(e,t,n){var r,i=0;if(t=t||"",n=n||{},Array.isArray(e))for(i=0;"undefined"!=typeof(r=e[i]);i++)d(r,t+"["+i+"]",n);else a(e)?s(e,(function(e,r){d(r,t?t+"["+e+"]":e,n)})):t&&"undefined"!=typeof e&&(n[t]=e);return n}function l(){this.readyState<4&&this.abort()}function p(e){var n,u=c.get(this),p="string"==typeof u.data,f=u.settings,h=u.url,m=p?u.data:d(u.data),T=h.local?new t:new o,g=r.defer(),w=l.bind(T),y=f.timeout;return m&&"GET"===e&&(p?h.parameter=m:s(m,h.parameter.set,h),m=null),f.cache||h.parameter.set("nucleus",+new Date),m&&!p&&(m=function(e){var t=new i("/");return s(e,t.parameter.set,t),t.search.substr(1)}(m)),a(f.xhrOptions)&&s(f.xhrOptions,(function(e,t){T[e]=t})),T.ontimeout=T.onerror=T.onabort=function(){g.reject(T)},T.onprogress=T.onreadystatechange=function(){clearTimeout(n),n=setTimeout(w,y)},T.onload=function(){n=clearTimeout(n),"status"in T&&200!==T.status?g.reject(T):g.resolve(T.responseText,T)},T.open(e,h.href,!0),T.setRequestHeader&&(T.setRequestHeader("Accept",f.accept),m&&"GET"!==e&&T.setRequestHeader("Content-Type",f.contentType),a(f.header)&&s(f.header,(function(e,t){T.setRequestHeader(e,t)}))),T.send(m),n=setTimeout(w,y),g.pledge}function f(e,t,n){return c.set(this,{settings:u({},f.settings,n),url:new i(e),data:t}),this}return f.prototype={get:function(){return p.call(this,"GET")},post:function(){return p.call(this,"POST")},put:function(){return p.call(this,"PUT")},patch:function(){return p.call(this,"PATCH")},delete:function(){return p.call(this,"DELETE")},head:function(){return p.call(this,"HEAD")}},f.settings={accept:"*/*",timeout:8e3,async:!0,cache:!1,username:null,password:null,contentType:"application/x-www-form-urlencoded; charset=UTF-8",header:{"x-requested-with":"XMLHttpRequest"},xhrOptions:{}},f}))}(this,XMLHttpRequest); //# sourceMappingURL=xhr.js.map