2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

Releasing 0.5.0

This commit is contained in:
mzabriskie
2015-01-23 03:11:24 -07:00
parent a9bcc8f419
commit fa6c26a0e5
19 changed files with 2884 additions and 1747 deletions
+6 -1
View File
@@ -45,4 +45,9 @@
- Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/mzabriskie/axios/issues/22)) - Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/mzabriskie/axios/issues/22))
- Adding support for TypeScript ([#25](https://github.com/mzabriskie/axios/issues/25)) - Adding support for TypeScript ([#25](https://github.com/mzabriskie/axios/issues/25))
- Fixing issue with standalone build ([#29](https://github.com/mzabriskie/axios/issues/29)) - Fixing issue with standalone build ([#29](https://github.com/mzabriskie/axios/issues/29))
- Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/mzabriskie/axios/issues/30)) - Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/mzabriskie/axios/issues/30))
### 0.5.0 (Jan 23, 2015)
- Adding support for intercepetors
- Updating es6-promise dependency
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "axios", "name": "axios",
"main": "./dist/axios.js", "main": "./dist/axios.js",
"version": "0.4.2", "version": "0.5.0",
"homepage": "https://github.com/mzabriskie/axios", "homepage": "https://github.com/mzabriskie/axios",
"authors": [ "authors": [
"Matt Zabriskie" "Matt Zabriskie"
+1198 -748
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+226 -117
View File
@@ -1,4 +1,4 @@
define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__) { return /******/ (function(modules) { // webpackBootstrap define("axios", ["{Promise: Promise}"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache /******/ // The module cache
/******/ var installedModules = {}; /******/ var installedModules = {};
/******/ /******/
@@ -50,9 +50,14 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
/* 1 */ /* 1 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {var Promise = __webpack_require__(2).Promise; var defaults = __webpack_require__(3);
var defaults = __webpack_require__(4); var utils = __webpack_require__(4);
var utils = __webpack_require__(5); var deprecatedMethod = __webpack_require__(5);
var dispatchRequest = __webpack_require__(6);
var InterceptorManager = __webpack_require__(7);
// Polyfill ES6 Promise if needed
__webpack_require__(2).polyfill();
var axios = module.exports = function axios(config) { var axios = module.exports = function axios(config) {
config = utils.merge({ config = utils.merge({
@@ -65,52 +70,20 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
// Don't allow overriding defaults.withCredentials // Don't allow overriding defaults.withCredentials
config.withCredentials = config.withCredentials || defaults.withCredentials; config.withCredentials = config.withCredentials || defaults.withCredentials;
var serverRequest = function (config) { // Hook up interceptors middleware
return new Promise(function (resolve, reject) { var chain = [dispatchRequest, undefined];
try {
// For browsers use XHR adapter
if (typeof window !== 'undefined') {
__webpack_require__(6)(resolve, reject, config);
}
// For node use HTTP adapter
else if (typeof process !== 'undefined') {
__webpack_require__(3)(resolve, reject, config);
}
} catch (e) {
reject(e);
}
});
};
function deprecatedMethod(method, instead, docs) {
try {
console.warn(
'DEPRECATED method `' + method + '`.' +
(instead ? ' Use `' + instead + '` instead.' : '') +
' This method will be removed in a future release.');
if (docs) {
console.warn('For more information about usage see ' + docs);
}
} catch (e) {}
}
var chain = [serverRequest, undefined];
var promise = Promise.resolve(config); var promise = Promise.resolve(config);
utils.forEach(axios.interceptors.request.handlers, function (interceptor) { axios.interceptors.request.forEach(function (interceptor) {
chain.unshift(interceptor.request, interceptor.requestError); chain.unshift(interceptor.fulfilled, interceptor.rejected);
}); });
utils.forEach(axios.interceptors.response.handlers, function (interceptor) { axios.interceptors.response.forEach(function (interceptor) {
chain.push(interceptor.response, interceptor.responseError); chain.push(interceptor.fulfilled, interceptor.rejected);
}); });
while (chain.length) { while (chain.length) {
var thenFn = chain.shift(); promise = promise.then(chain.shift(), chain.shift());
var rejectFn = chain.shift();
promise = promise.then(thenFn, rejectFn);
} }
// Provide alias for success // Provide alias for success
@@ -143,22 +116,12 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
axios.all = function (promises) { axios.all = function (promises) {
return Promise.all(promises); return Promise.all(promises);
}; };
axios.spread = __webpack_require__(7); axios.spread = __webpack_require__(8);
// interceptors // Expose interceptors
axios.interceptors = { axios.interceptors = {
request: { request: new InterceptorManager(),
handlers: [], response: new InterceptorManager()
use: function (thenFn, rejectFn) {
axios.interceptors.request.handlers.push({ request: thenFn, requestError: rejectFn });
}
},
response: {
handlers: [],
use: function (thenFn, rejectFn) {
axios.interceptors.response.handlers.push({ response: thenFn, responseError: rejectFn });
}
}
}; };
// Provide aliases for supported request methods // Provide aliases for supported request methods
@@ -188,7 +151,7 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
}); });
} }
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))
/***/ }, /***/ },
/* 2 */ /* 2 */
@@ -198,18 +161,11 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
/***/ }, /***/ },
/* 3 */ /* 3 */
/***/ function(module, exports, __webpack_require__) {
if(typeof undefined === 'undefined') {var e = new Error("Cannot find module \"undefined\""); e.code = 'MODULE_NOT_FOUND'; throw e;}
module.exports = undefined;
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
var JSON_START = /^\s*(\[|\{[^\{])/; var JSON_START = /^\s*(\[|\{[^\{])/;
var JSON_END = /[\}\]]\s*$/; var JSON_END = /[\}\]]\s*$/;
@@ -260,7 +216,7 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
}; };
/***/ }, /***/ },
/* 5 */ /* 4 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
// utils is a library of generic helper functions non-specific to axios // utils is a library of generic helper functions non-specific to axios
@@ -477,17 +433,169 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
trim: trim trim: trim
}; };
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* Supply a warning to the developer that a method they are using
* has been deprecated.
*
* @param {string} method The name of the deprecated method
* @param {string} [instead] The alternate method to use if applicable
* @param {string} [docs] The documentation URL to get further details
*/
module.exports = function deprecatedMethod(method, instead, docs) {
try {
console.warn(
'DEPRECATED method `' + method + '`.' +
(instead ? ' Use `' + instead + '` instead.' : '') +
' This method will be removed in a future release.');
if (docs) {
console.warn('For more information about usage see ' + docs);
}
} catch (e) {}
};
/***/ }, /***/ },
/* 6 */ /* 6 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
var defaults = __webpack_require__(4); /* WEBPACK VAR INJECTION */(function(process) {'use strict';
var utils = __webpack_require__(5);
var buildUrl = __webpack_require__(9); var Promise = __webpack_require__(2).Promise;
var cookies = __webpack_require__(10);
var parseHeaders = __webpack_require__(11); /**
var transformData = __webpack_require__(12); * Dispatch a request to the server using whichever adapter
var urlIsSameOrigin = __webpack_require__(13); * is supported by the current environment.
*
* @param {object} config The config that is to be used for the request
* @returns {Promise} The Promise to be fulfilled
*/
module.exports = function dispatchRequest(config) {
return new Promise(function (resolve, reject) {
try {
// For browsers use XHR adapter
if (typeof window !== 'undefined') {
__webpack_require__(9)(resolve, reject, config);
}
// For node use HTTP adapter
else if (typeof process !== 'undefined') {
__webpack_require__(9)(resolve, reject, config);
}
} catch (e) {
reject(e);
}
});
};
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)))
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(4);
function InterceptorManager() {
this.handlers = [];
};
/**
* Add a new interceptor to the stack
*
* @param {Function} fulfilled The function to handle `then` for a `Promise`
* @param {Function} rejected The function to handle `reject` for a `Promise`
*
* @return {Number} An ID used to remove interceptor later
*/
InterceptorManager.prototype.use = function (fulfilled, rejected) {
this.handlers.push({
fulfilled: fulfilled,
rejected: rejected
});
return this.handlers.length - 1;
};
/**
* Remove an interceptor from the stack
*
* @param {Number} id The ID that was returned by `use`
*/
InterceptorManager.prototype.eject = function (id) {
if (this.handlers[id]) {
this.handlers[id] = null;
}
};
/**
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become `null` calling `remove`.
*
* @param {Function} fn The function to call for each interceptor
*/
InterceptorManager.prototype.forEach = function (fn) {
utils.forEach(this.handlers, function (h) {
if (h !== null) {
fn(h);
}
});
};
module.exports = InterceptorManager;
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
/**
* Syntactic sugar for invoking a function and expanding an array for arguments.
*
* Common use case would be to use `Function.prototype.apply`.
*
* ```js
* function f(x, y, z) {}
* var args = [1, 2, 3];
* f.apply(null, args);
* ```
*
* With `spread` this example can be re-written.
*
* ```js
* spread(function(x, y, z) {})([1, 2, 3]);
* ```
*
* @param {Function} callback
* @returns {Function}
*/
module.exports = function spread(callback) {
return function (arr) {
callback.apply(null, arr);
};
};
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
var defaults = __webpack_require__(3);
var utils = __webpack_require__(4);
var buildUrl = __webpack_require__(11);
var cookies = __webpack_require__(12);
var parseHeaders = __webpack_require__(13);
var transformData = __webpack_require__(14);
var urlIsSameOrigin = __webpack_require__(15);
module.exports = function xhrAdapter(resolve, reject, config) { module.exports = function xhrAdapter(resolve, reject, config) {
// Transform request data // Transform request data
@@ -583,37 +691,7 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
}; };
/***/ }, /***/ },
/* 7 */ /* 10 */
/***/ function(module, exports, __webpack_require__) {
/**
* Syntactic sugar for invoking a function and expanding an array for arguments.
*
* Common use case would be to use `Function.prototype.apply`.
*
* ```js
* function f(x, y, z) {}
* var args = [1, 2, 3];
* f.apply(null, args);
* ```
*
* With `spread` this example can be re-written.
*
* ```js
* spread(function(x, y, z) {})([1, 2, 3]);
* ```
*
* @param {Function} callback
* @returns {Function}
*/
module.exports = function spread(callback) {
return function (arr) {
callback.apply(null, arr);
};
};
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
// shim for using process in browser // shim for using process in browser
@@ -623,6 +701,8 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
process.nextTick = (function () { process.nextTick = (function () {
var canSetImmediate = typeof window !== 'undefined' var canSetImmediate = typeof window !== 'undefined'
&& window.setImmediate; && window.setImmediate;
var canMutationObserver = typeof window !== 'undefined'
&& window.MutationObserver;
var canPost = typeof window !== 'undefined' var canPost = typeof window !== 'undefined'
&& window.postMessage && window.addEventListener && window.postMessage && window.addEventListener
; ;
@@ -631,8 +711,29 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
return function (f) { return window.setImmediate(f) }; return function (f) { return window.setImmediate(f) };
} }
var queue = [];
if (canMutationObserver) {
var hiddenDiv = document.createElement("div");
var observer = new MutationObserver(function () {
var queueList = queue.slice();
queue.length = 0;
queueList.forEach(function (fn) {
fn();
});
});
observer.observe(hiddenDiv, { attributes: true });
return function nextTick(fn) {
if (!queue.length) {
hiddenDiv.setAttribute('yes', 'no');
}
queue.push(fn);
};
}
if (canPost) { if (canPost) {
var queue = [];
window.addEventListener('message', function (ev) { window.addEventListener('message', function (ev) {
var source = ev.source; var source = ev.source;
if ((source === window || source === null) && ev.data === 'process-tick') { if ((source === window || source === null) && ev.data === 'process-tick') {
@@ -672,7 +773,7 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
process.binding = function (name) { process.binding = function (name) {
throw new Error('process.binding is not supported'); throw new Error('process.binding is not supported');
} };
// TODO(shtylman) // TODO(shtylman)
process.cwd = function () { return '/' }; process.cwd = function () { return '/' };
@@ -682,12 +783,12 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
/***/ }, /***/ },
/* 9 */ /* 11 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
function encode(val) { function encode(val) {
return encodeURIComponent(val). return encodeURIComponent(val).
@@ -698,6 +799,13 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
replace(/%20/g, '+'); replace(/%20/g, '+');
} }
/**
* Build a URL by appending params to the end
*
* @param {string} url The base of the url (e.g., http://www.google.com)
* @param {object} [params] The params to be appended
* @returns {string} The formatted url
*/
module.exports = function buildUrl(url, params) { module.exports = function buildUrl(url, params) {
if (!params) { if (!params) {
return url; return url;
@@ -731,13 +839,14 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
return url; return url;
}; };
/***/ }, /***/ },
/* 10 */ /* 12 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
module.exports = { module.exports = {
write: function write(name, value, expires, path, domain, secure) { write: function write(name, value, expires, path, domain, secure) {
@@ -774,12 +883,12 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
}; };
/***/ }, /***/ },
/* 11 */ /* 13 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
/** /**
* Parse headers into an object * Parse headers into an object
@@ -813,12 +922,12 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
}; };
/***/ }, /***/ },
/* 12 */ /* 14 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
/** /**
* Transform the data for a request or a response * Transform the data for a request or a response
@@ -837,13 +946,13 @@ define("axios", ["{Promise: Promise}","undefined"], function(__WEBPACK_EXTERNAL_
}; };
/***/ }, /***/ },
/* 13 */ /* 15 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var msie = /(msie|trident)/i.test(navigator.userAgent); var msie = /(msie|trident)/i.test(navigator.userAgent);
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
var urlParsingNode = document.createElement('a'); var urlParsingNode = document.createElement('a');
var originUrl = urlResolve(window.location.href); var originUrl = urlResolve(window.location.href);
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1197 -747
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+225 -116
View File
@@ -51,9 +51,14 @@ var axios =
/* 1 */ /* 1 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process) {var Promise = __webpack_require__(2).Promise; var defaults = __webpack_require__(3);
var defaults = __webpack_require__(4); var utils = __webpack_require__(4);
var utils = __webpack_require__(5); var deprecatedMethod = __webpack_require__(5);
var dispatchRequest = __webpack_require__(6);
var InterceptorManager = __webpack_require__(7);
// Polyfill ES6 Promise if needed
__webpack_require__(2).polyfill();
var axios = module.exports = function axios(config) { var axios = module.exports = function axios(config) {
config = utils.merge({ config = utils.merge({
@@ -66,52 +71,20 @@ var axios =
// Don't allow overriding defaults.withCredentials // Don't allow overriding defaults.withCredentials
config.withCredentials = config.withCredentials || defaults.withCredentials; config.withCredentials = config.withCredentials || defaults.withCredentials;
var serverRequest = function (config) { // Hook up interceptors middleware
return new Promise(function (resolve, reject) { var chain = [dispatchRequest, undefined];
try {
// For browsers use XHR adapter
if (typeof window !== 'undefined') {
__webpack_require__(6)(resolve, reject, config);
}
// For node use HTTP adapter
else if (typeof process !== 'undefined') {
__webpack_require__(3)(resolve, reject, config);
}
} catch (e) {
reject(e);
}
});
};
function deprecatedMethod(method, instead, docs) {
try {
console.warn(
'DEPRECATED method `' + method + '`.' +
(instead ? ' Use `' + instead + '` instead.' : '') +
' This method will be removed in a future release.');
if (docs) {
console.warn('For more information about usage see ' + docs);
}
} catch (e) {}
}
var chain = [serverRequest, undefined];
var promise = Promise.resolve(config); var promise = Promise.resolve(config);
utils.forEach(axios.interceptors.request.handlers, function (interceptor) { axios.interceptors.request.forEach(function (interceptor) {
chain.unshift(interceptor.request, interceptor.requestError); chain.unshift(interceptor.fulfilled, interceptor.rejected);
}); });
utils.forEach(axios.interceptors.response.handlers, function (interceptor) { axios.interceptors.response.forEach(function (interceptor) {
chain.push(interceptor.response, interceptor.responseError); chain.push(interceptor.fulfilled, interceptor.rejected);
}); });
while (chain.length) { while (chain.length) {
var thenFn = chain.shift(); promise = promise.then(chain.shift(), chain.shift());
var rejectFn = chain.shift();
promise = promise.then(thenFn, rejectFn);
} }
// Provide alias for success // Provide alias for success
@@ -144,22 +117,12 @@ var axios =
axios.all = function (promises) { axios.all = function (promises) {
return Promise.all(promises); return Promise.all(promises);
}; };
axios.spread = __webpack_require__(7); axios.spread = __webpack_require__(8);
// interceptors // Expose interceptors
axios.interceptors = { axios.interceptors = {
request: { request: new InterceptorManager(),
handlers: [], response: new InterceptorManager()
use: function (thenFn, rejectFn) {
axios.interceptors.request.handlers.push({ request: thenFn, requestError: rejectFn });
}
},
response: {
handlers: [],
use: function (thenFn, rejectFn) {
axios.interceptors.response.handlers.push({ response: thenFn, responseError: rejectFn });
}
}
}; };
// Provide aliases for supported request methods // Provide aliases for supported request methods
@@ -189,7 +152,7 @@ var axios =
}); });
} }
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))
/***/ }, /***/ },
/* 2 */ /* 2 */
@@ -199,18 +162,11 @@ var axios =
/***/ }, /***/ },
/* 3 */ /* 3 */
/***/ function(module, exports, __webpack_require__) {
if(typeof undefined === 'undefined') {var e = new Error("Cannot find module \"undefined\""); e.code = 'MODULE_NOT_FOUND'; throw e;}
module.exports = undefined;
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
var JSON_START = /^\s*(\[|\{[^\{])/; var JSON_START = /^\s*(\[|\{[^\{])/;
var JSON_END = /[\}\]]\s*$/; var JSON_END = /[\}\]]\s*$/;
@@ -261,7 +217,7 @@ var axios =
}; };
/***/ }, /***/ },
/* 5 */ /* 4 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
// utils is a library of generic helper functions non-specific to axios // utils is a library of generic helper functions non-specific to axios
@@ -478,17 +434,169 @@ var axios =
trim: trim trim: trim
}; };
/***/ },
/* 5 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
/**
* Supply a warning to the developer that a method they are using
* has been deprecated.
*
* @param {string} method The name of the deprecated method
* @param {string} [instead] The alternate method to use if applicable
* @param {string} [docs] The documentation URL to get further details
*/
module.exports = function deprecatedMethod(method, instead, docs) {
try {
console.warn(
'DEPRECATED method `' + method + '`.' +
(instead ? ' Use `' + instead + '` instead.' : '') +
' This method will be removed in a future release.');
if (docs) {
console.warn('For more information about usage see ' + docs);
}
} catch (e) {}
};
/***/ }, /***/ },
/* 6 */ /* 6 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
var defaults = __webpack_require__(4); /* WEBPACK VAR INJECTION */(function(process) {'use strict';
var utils = __webpack_require__(5);
var buildUrl = __webpack_require__(9); var Promise = __webpack_require__(2).Promise;
var cookies = __webpack_require__(10);
var parseHeaders = __webpack_require__(11); /**
var transformData = __webpack_require__(12); * Dispatch a request to the server using whichever adapter
var urlIsSameOrigin = __webpack_require__(13); * is supported by the current environment.
*
* @param {object} config The config that is to be used for the request
* @returns {Promise} The Promise to be fulfilled
*/
module.exports = function dispatchRequest(config) {
return new Promise(function (resolve, reject) {
try {
// For browsers use XHR adapter
if (typeof window !== 'undefined') {
__webpack_require__(9)(resolve, reject, config);
}
// For node use HTTP adapter
else if (typeof process !== 'undefined') {
__webpack_require__(9)(resolve, reject, config);
}
} catch (e) {
reject(e);
}
});
};
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10)))
/***/ },
/* 7 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
var utils = __webpack_require__(4);
function InterceptorManager() {
this.handlers = [];
};
/**
* Add a new interceptor to the stack
*
* @param {Function} fulfilled The function to handle `then` for a `Promise`
* @param {Function} rejected The function to handle `reject` for a `Promise`
*
* @return {Number} An ID used to remove interceptor later
*/
InterceptorManager.prototype.use = function (fulfilled, rejected) {
this.handlers.push({
fulfilled: fulfilled,
rejected: rejected
});
return this.handlers.length - 1;
};
/**
* Remove an interceptor from the stack
*
* @param {Number} id The ID that was returned by `use`
*/
InterceptorManager.prototype.eject = function (id) {
if (this.handlers[id]) {
this.handlers[id] = null;
}
};
/**
* Iterate over all the registered interceptors
*
* This method is particularly useful for skipping over any
* interceptors that may have become `null` calling `remove`.
*
* @param {Function} fn The function to call for each interceptor
*/
InterceptorManager.prototype.forEach = function (fn) {
utils.forEach(this.handlers, function (h) {
if (h !== null) {
fn(h);
}
});
};
module.exports = InterceptorManager;
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) {
/**
* Syntactic sugar for invoking a function and expanding an array for arguments.
*
* Common use case would be to use `Function.prototype.apply`.
*
* ```js
* function f(x, y, z) {}
* var args = [1, 2, 3];
* f.apply(null, args);
* ```
*
* With `spread` this example can be re-written.
*
* ```js
* spread(function(x, y, z) {})([1, 2, 3]);
* ```
*
* @param {Function} callback
* @returns {Function}
*/
module.exports = function spread(callback) {
return function (arr) {
callback.apply(null, arr);
};
};
/***/ },
/* 9 */
/***/ function(module, exports, __webpack_require__) {
var defaults = __webpack_require__(3);
var utils = __webpack_require__(4);
var buildUrl = __webpack_require__(11);
var cookies = __webpack_require__(12);
var parseHeaders = __webpack_require__(13);
var transformData = __webpack_require__(14);
var urlIsSameOrigin = __webpack_require__(15);
module.exports = function xhrAdapter(resolve, reject, config) { module.exports = function xhrAdapter(resolve, reject, config) {
// Transform request data // Transform request data
@@ -584,37 +692,7 @@ var axios =
}; };
/***/ }, /***/ },
/* 7 */ /* 10 */
/***/ function(module, exports, __webpack_require__) {
/**
* Syntactic sugar for invoking a function and expanding an array for arguments.
*
* Common use case would be to use `Function.prototype.apply`.
*
* ```js
* function f(x, y, z) {}
* var args = [1, 2, 3];
* f.apply(null, args);
* ```
*
* With `spread` this example can be re-written.
*
* ```js
* spread(function(x, y, z) {})([1, 2, 3]);
* ```
*
* @param {Function} callback
* @returns {Function}
*/
module.exports = function spread(callback) {
return function (arr) {
callback.apply(null, arr);
};
};
/***/ },
/* 8 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
// shim for using process in browser // shim for using process in browser
@@ -624,6 +702,8 @@ var axios =
process.nextTick = (function () { process.nextTick = (function () {
var canSetImmediate = typeof window !== 'undefined' var canSetImmediate = typeof window !== 'undefined'
&& window.setImmediate; && window.setImmediate;
var canMutationObserver = typeof window !== 'undefined'
&& window.MutationObserver;
var canPost = typeof window !== 'undefined' var canPost = typeof window !== 'undefined'
&& window.postMessage && window.addEventListener && window.postMessage && window.addEventListener
; ;
@@ -632,8 +712,29 @@ var axios =
return function (f) { return window.setImmediate(f) }; return function (f) { return window.setImmediate(f) };
} }
var queue = [];
if (canMutationObserver) {
var hiddenDiv = document.createElement("div");
var observer = new MutationObserver(function () {
var queueList = queue.slice();
queue.length = 0;
queueList.forEach(function (fn) {
fn();
});
});
observer.observe(hiddenDiv, { attributes: true });
return function nextTick(fn) {
if (!queue.length) {
hiddenDiv.setAttribute('yes', 'no');
}
queue.push(fn);
};
}
if (canPost) { if (canPost) {
var queue = [];
window.addEventListener('message', function (ev) { window.addEventListener('message', function (ev) {
var source = ev.source; var source = ev.source;
if ((source === window || source === null) && ev.data === 'process-tick') { if ((source === window || source === null) && ev.data === 'process-tick') {
@@ -673,7 +774,7 @@ var axios =
process.binding = function (name) { process.binding = function (name) {
throw new Error('process.binding is not supported'); throw new Error('process.binding is not supported');
} };
// TODO(shtylman) // TODO(shtylman)
process.cwd = function () { return '/' }; process.cwd = function () { return '/' };
@@ -683,12 +784,12 @@ var axios =
/***/ }, /***/ },
/* 9 */ /* 11 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
function encode(val) { function encode(val) {
return encodeURIComponent(val). return encodeURIComponent(val).
@@ -699,6 +800,13 @@ var axios =
replace(/%20/g, '+'); replace(/%20/g, '+');
} }
/**
* Build a URL by appending params to the end
*
* @param {string} url The base of the url (e.g., http://www.google.com)
* @param {object} [params] The params to be appended
* @returns {string} The formatted url
*/
module.exports = function buildUrl(url, params) { module.exports = function buildUrl(url, params) {
if (!params) { if (!params) {
return url; return url;
@@ -732,13 +840,14 @@ var axios =
return url; return url;
}; };
/***/ }, /***/ },
/* 10 */ /* 12 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
module.exports = { module.exports = {
write: function write(name, value, expires, path, domain, secure) { write: function write(name, value, expires, path, domain, secure) {
@@ -775,12 +884,12 @@ var axios =
}; };
/***/ }, /***/ },
/* 11 */ /* 13 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
/** /**
* Parse headers into an object * Parse headers into an object
@@ -814,12 +923,12 @@ var axios =
}; };
/***/ }, /***/ },
/* 12 */ /* 14 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
/** /**
* Transform the data for a request or a response * Transform the data for a request or a response
@@ -838,13 +947,13 @@ var axios =
}; };
/***/ }, /***/ },
/* 13 */ /* 15 */
/***/ function(module, exports, __webpack_require__) { /***/ function(module, exports, __webpack_require__) {
'use strict'; 'use strict';
var msie = /(msie|trident)/i.test(navigator.userAgent); var msie = /(msie|trident)/i.test(navigator.userAgent);
var utils = __webpack_require__(5); var utils = __webpack_require__(4);
var urlParsingNode = document.createElement('a'); var urlParsingNode = document.createElement('a');
var originUrl = urlResolve(window.location.href); var originUrl = urlResolve(window.location.href);
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "axios", "name": "axios",
"version": "0.4.2", "version": "0.5.0",
"description": "Promise based HTTP client for the browser and node.js", "description": "Promise based HTTP client for the browser and node.js",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {