mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
3 lines
9.0 KiB
JavaScript
3 lines
9.0 KiB
JavaScript
/* axios v0.0.0 | (c) 2014 by Matt Zabriskie */
|
|
define("axios",[],function(){return function(t){function n(r){if(e[r])return e[r].exports;var o=e[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var e={};return n.m=t,n.c=e,n.p="",n(0)}([function(t,n,e){t.exports=e(1)},function(t,n,e){function r(){f.forEach(arguments,function(t){l[t]=function(n,e){return l(f.merge(e||{},{method:t,url:n}))}})}function o(){f.forEach(arguments,function(t){l[t]=function(n,e,r){return l(f.merge(r||{},{method:t,url:n,data:e}))}})}var i=e(7).Promise,s=e(2),c=e(3),u=e(4),a=e(5),f=e(6),l=t.exports=function(t){t=f.merge({method:"get",transformRequest:c.transformRequest,transformResponse:c.transformResponse},t),t.withCredentials=t.withCredentials||c.withCredentials;var n=new i(function(n,e){var r=new(XMLHttpRequest||ActiveXObject)("Microsoft.XMLHTTP"),o=a(t.data,t.headers,t.transformRequest);r.open(t.method,s(t.url,t.params),!0),r.onreadystatechange=function(){if(r&&4===r.readyState){var o=u(r.getAllResponseHeaders()),i={data:a(r.responseText,o,t.transformResponse),status:r.status,headers:o,config:t};r.status>=200&&r.status<300?n(i):e(i),r=null}};var i=f.merge(c.headers.common,c.headers[t.method]||{},t.headers||{});if(f.forEach(i,function(t,n){"undefined"==typeof o&&"content-type"===n.toLowerCase()?delete i[n]:r.setRequestHeader(n,t)}),t.withCredentials&&(r.withCredentials=!0),t.responseType)try{r.responseType=t.responseType}catch(l){if("json"!==r.responseType)throw l}r.send(o)});return n.success=function(t){return n.then(function(n){t(n)}),n},n.error=function(t){return n.then(null,function(n){t(n)}),n},n};l.defaults=c,r("delete","get","head"),o("post","put","patch")},function(t,n,e){"use strict";function r(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}var o=e(6);t.exports=function(t,n){if(!n)return t;var e=[];return o.forEach(n,function(t,n){null!==t&&"undefined"!=typeof t&&(o.isArray(t)||(t=[t]),o.forEach(t,function(t){o.isDate(t)?t=t.toISOString():o.isObject(t)&&(t=JSON.stringify(t)),e.push(r(n)+"="+r(t))}))}),e.length>0&&(t+=(-1===t.indexOf("?")?"?":"&")+e.join("&")),t}},function(t,n,e){"use strict";var r=e(6),o=/^\s*(\[|\{[^\{])/,i=/[\}\]]\s*$/,s=/^\)\]\}',?\n/,c={"Content-Type":"application/json;charset=utf-8"};t.exports={transformRequest:[function(t){return!r.isObject(t)||r.isFile(t)||r.isBlob(t)?null:JSON.stringify(t)}],transformResponse:[function(t){return"string"==typeof t&&(t=t.replace(s,""),o.test(t)&&i.test(t)&&(t=JSON.parse(t))),t}],headers:{common:{Accept:"application/json, text/plain, */*"},patch:r.merge(c),post:r.merge(c),put:r.merge(c)},xsrfCookiName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN"}},function(t,n,e){"use strict";var r=e(6);t.exports=function(t){var n,e,o,i={};return t?(r.forEach(t.split("\n"),function(t){o=t.indexOf(":"),n=r.trim(t.substr(0,o)).toLowerCase(),e=r.trim(t.substr(o+1)),n&&(i[n]=i[n]?i[n]+", "+e:e)}),i):i}},function(t,n,e){"use strict";var r=e(6);t.exports=function(t,n,e){return r.forEach(e,function(e){t=e(t,n)}),t}},function(t){function n(t){return"[object Array]"===a.call(t)}function e(t){return null!==t&&"object"==typeof t}function r(t){return"[object Date]"===a.call(t)}function o(t){return"[object File]"===a.call(t)}function i(t){return"[object Blob]"!==a.call(t)}function s(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}function c(t,n){if(null!==t&&"undefined"!=typeof t){var e=t.constructor===Array||"function"==typeof t.callee;if("object"==typeof t||e||(t=[t]),e)for(var r=0,o=t.length;o>r;r++)n.call(null,t[r],r,t);else for(var i in t)t.hasOwnProperty(i)&&n.call(null,t[i],i,t)}}function u(){var t={};return c(arguments,function(n){c(n,function(n,e){t[e]=n})}),t}var a=Object.prototype.toString;t.exports={isArray:n,isObject:e,isDate:r,isFile:o,isBlob:i,forEach:c,merge:u,trim:s}},function(t,n,e){"use strict";var r=e(8).Promise,o=e(9).polyfill;n.Promise=r,n.polyfill=o},function(t,n,e){"use strict";function r(t){if(!m(t))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof r))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],o(t,this)}function o(t,n){function e(t){a(n,t)}function r(t){l(n,t)}try{t(e,r)}catch(o){r(o)}}function i(t,n,e,r){var o,i,s,c,f=m(e);if(f)try{o=e(r),s=!0}catch(p){c=!0,i=p}else o=r,s=!0;u(n,o)||(f&&s?a(n,o):c?l(n,i):t===_?a(n,o):t===E&&l(n,o))}function s(t,n,e,r){var o=t._subscribers,i=o.length;o[i]=n,o[i+_]=e,o[i+E]=r}function c(t,n){for(var e,r,o=t._subscribers,s=t._detail,c=0;c<o.length;c+=3)e=o[c],r=o[c+n],i(n,e,r,s);t._subscribers=null}function u(t,n){var e,r=null;try{if(t===n)throw new TypeError("A promises callback cannot return that same promise.");if(v(n)&&(r=n.then,m(r)))return r.call(n,function(r){return e?!0:(e=!0,void(n!==r?a(t,r):f(t,r)))},function(n){return e?!0:(e=!0,void l(t,n))}),!0}catch(o){return e?!0:(l(t,o),!0)}return!1}function a(t,n){t===n?f(t,n):u(t,n)||f(t,n)}function f(t,n){t._state===x&&(t._state=T,t._detail=n,h.async(p,t))}function l(t,n){t._state===x&&(t._state=T,t._detail=n,h.async(d,t))}function p(t){c(t,t._state=_)}function d(t){c(t,t._state=E)}var h=e(10).config,v=(e(10).configure,e(11).objectOrFunction),m=e(11).isFunction,w=(e(11).now,e(12).all),y=e(13).race,g=e(14).resolve,b=e(15).reject,j=e(16).asap;h.async=j;var x=void 0,T=0,_=1,E=2;r.prototype={constructor:r,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(t,n){var e=this,r=new this.constructor(function(){});if(this._state){var o=arguments;h.async(function(){i(e._state,r,o[e._state-1],e._detail)})}else s(this,r,t,n);return r},"catch":function(t){return this.then(null,t)}},r.all=w,r.race=y,r.resolve=g,r.reject=b,n.Promise=r},function(t,n,e){(function(t){"use strict";function r(){var n;n="undefined"!=typeof t?t:"undefined"!=typeof window&&window.document?window:self;var e="Promise"in n&&"resolve"in n.Promise&&"reject"in n.Promise&&"all"in n.Promise&&"race"in n.Promise&&function(){var t;return new n.Promise(function(n){t=n}),i(t)}();e||(n.Promise=o)}var o=e(8).Promise,i=e(11).isFunction;n.polyfill=r}).call(n,function(){return this}())},function(t,n){"use strict";function e(t,n){return 2!==arguments.length?r[t]:void(r[t]=n)}var r={instrument:!1};n.config=r,n.configure=e},function(t,n){"use strict";function e(t){return r(t)||"object"==typeof t&&null!==t}function r(t){return"function"==typeof t}function o(t){return"[object Array]"===Object.prototype.toString.call(t)}var i=Date.now||function(){return(new Date).getTime()};n.objectOrFunction=e,n.isFunction=r,n.isArray=o,n.now=i},function(t,n,e){"use strict";function r(t){var n=this;if(!o(t))throw new TypeError("You must pass an array to all.");return new n(function(n,e){function r(t){return function(n){o(t,n)}}function o(t,e){c[t]=e,0===--u&&n(c)}var s,c=[],u=t.length;0===u&&n([]);for(var a=0;a<t.length;a++)s=t[a],s&&i(s.then)?s.then(r(a),e):o(a,s)})}var o=e(11).isArray,i=e(11).isFunction;n.all=r},function(t,n,e){"use strict";function r(t){var n=this;if(!o(t))throw new TypeError("You must pass an array to race.");return new n(function(n,e){for(var r,o=0;o<t.length;o++)r=t[o],r&&"function"==typeof r.then?r.then(n,e):n(r)})}var o=e(11).isArray;n.race=r},function(t,n){"use strict";function e(t){if(t&&"object"==typeof t&&t.constructor===this)return t;var n=this;return new n(function(n){n(t)})}n.resolve=e},function(t,n){"use strict";function e(t){var n=this;return new n(function(n,e){e(t)})}n.reject=e},function(t,n,e){(function(t,e){"use strict";function r(){return function(){e.nextTick(s)}}function o(){var t=0,n=new f(s),e=document.createTextNode("");return n.observe(e,{characterData:!0}),function(){e.data=t=++t%2}}function i(){return function(){l.setTimeout(s,1)}}function s(){for(var t=0;t<p.length;t++){var n=p[t],e=n[0],r=n[1];e(r)}p=[]}function c(t,n){var e=p.push([t,n]);1===e&&u()}var u,a="undefined"!=typeof window?window:{},f=a.MutationObserver||a.WebKitMutationObserver,l="undefined"!=typeof t?t:void 0===this?window:this,p=[];u="undefined"!=typeof e&&"[object process]"==={}.toString.call(e)?r():f?o():i(),n.asap=c}).call(n,function(){return this}(),e(17))},function(t){function n(){}var e=t.exports={};e.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(n){var e=[];return window.addEventListener("message",function(t){var n=t.source;if((n===window||null===n)&&"process-tick"===t.data&&(t.stopPropagation(),e.length>0)){var r=e.shift();r()}},!0),function(t){e.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.on=n,e.addListener=n,e.once=n,e.off=n,e.removeListener=n,e.removeAllListeners=n,e.emit=n,e.binding=function(){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(){throw new Error("process.chdir is not supported")}}])});
|
|
//# sourceMappingURL=axios.amd.min.map
|