mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
Adding support for all and spread
This commit is contained in:
Vendored
+66
-31
@@ -50,7 +50,7 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
/* 1 */
|
/* 1 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
var Promise = __webpack_require__(9).Promise;
|
var Promise = __webpack_require__(10).Promise;
|
||||||
var buildUrl = __webpack_require__(2);
|
var buildUrl = __webpack_require__(2);
|
||||||
var cookies = __webpack_require__(3);
|
var cookies = __webpack_require__(3);
|
||||||
var defaults = __webpack_require__(4);
|
var defaults = __webpack_require__(4);
|
||||||
@@ -58,6 +58,7 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
var transformData = __webpack_require__(6);
|
var transformData = __webpack_require__(6);
|
||||||
var urlIsSameOrigin = __webpack_require__(7);
|
var urlIsSameOrigin = __webpack_require__(7);
|
||||||
var utils = __webpack_require__(8);
|
var utils = __webpack_require__(8);
|
||||||
|
var spread = __webpack_require__(9);
|
||||||
|
|
||||||
var axios = module.exports = function axios(config) {
|
var axios = module.exports = function axios(config) {
|
||||||
config = utils.merge({
|
config = utils.merge({
|
||||||
@@ -180,6 +181,10 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
// Expose defaults
|
// Expose defaults
|
||||||
axios.defaults = defaults;
|
axios.defaults = defaults;
|
||||||
|
|
||||||
|
// Expose all/spread
|
||||||
|
axios.all = Promise.all;
|
||||||
|
axios.spread = spread;
|
||||||
|
|
||||||
// Provide aliases for supported request methods
|
// Provide aliases for supported request methods
|
||||||
createShortMethods('delete', 'get', 'head');
|
createShortMethods('delete', 'get', 'head');
|
||||||
createShortMethodsWithData('post', 'put', 'patch');
|
createShortMethodsWithData('post', 'put', 'patch');
|
||||||
@@ -637,27 +642,57 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
/* 9 */
|
/* 9 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
var Promise = __webpack_require__(10).Promise;
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
||||||
var polyfill = __webpack_require__(11).polyfill;
|
*
|
||||||
exports.Promise = Promise;
|
* Common use case would be to use `Function.prototype.apply`.
|
||||||
exports.polyfill = polyfill;
|
*
|
||||||
|
* ```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);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 10 */
|
/* 10 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
var config = __webpack_require__(12).config;
|
var Promise = __webpack_require__(11).Promise;
|
||||||
var configure = __webpack_require__(12).configure;
|
var polyfill = __webpack_require__(12).polyfill;
|
||||||
var objectOrFunction = __webpack_require__(13).objectOrFunction;
|
exports.Promise = Promise;
|
||||||
var isFunction = __webpack_require__(13).isFunction;
|
exports.polyfill = polyfill;
|
||||||
var now = __webpack_require__(13).now;
|
|
||||||
var all = __webpack_require__(14).all;
|
/***/ },
|
||||||
var race = __webpack_require__(15).race;
|
/* 11 */
|
||||||
var staticResolve = __webpack_require__(16).resolve;
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
var staticReject = __webpack_require__(17).reject;
|
|
||||||
var asap = __webpack_require__(18).asap;
|
"use strict";
|
||||||
|
var config = __webpack_require__(13).config;
|
||||||
|
var configure = __webpack_require__(13).configure;
|
||||||
|
var objectOrFunction = __webpack_require__(14).objectOrFunction;
|
||||||
|
var isFunction = __webpack_require__(14).isFunction;
|
||||||
|
var now = __webpack_require__(14).now;
|
||||||
|
var all = __webpack_require__(15).all;
|
||||||
|
var race = __webpack_require__(16).race;
|
||||||
|
var staticResolve = __webpack_require__(17).resolve;
|
||||||
|
var staticReject = __webpack_require__(18).reject;
|
||||||
|
var asap = __webpack_require__(19).asap;
|
||||||
|
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
|
|
||||||
@@ -860,13 +895,13 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
exports.Promise = Promise;
|
exports.Promise = Promise;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 11 */
|
/* 12 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
/* WEBPACK VAR INJECTION */(function(global) {"use strict";
|
/* WEBPACK VAR INJECTION */(function(global) {"use strict";
|
||||||
/*global self*/
|
/*global self*/
|
||||||
var RSVPPromise = __webpack_require__(10).Promise;
|
var RSVPPromise = __webpack_require__(11).Promise;
|
||||||
var isFunction = __webpack_require__(13).isFunction;
|
var isFunction = __webpack_require__(14).isFunction;
|
||||||
|
|
||||||
function polyfill() {
|
function polyfill() {
|
||||||
var local;
|
var local;
|
||||||
@@ -904,7 +939,7 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 12 */
|
/* 13 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -924,7 +959,7 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
exports.configure = configure;
|
exports.configure = configure;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 13 */
|
/* 14 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -951,14 +986,14 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
exports.now = now;
|
exports.now = now;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 14 */
|
/* 15 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/* global toString */
|
/* global toString */
|
||||||
|
|
||||||
var isArray = __webpack_require__(13).isArray;
|
var isArray = __webpack_require__(14).isArray;
|
||||||
var isFunction = __webpack_require__(13).isFunction;
|
var isFunction = __webpack_require__(14).isFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a promise that is fulfilled when all the given promises have been
|
Returns a promise that is fulfilled when all the given promises have been
|
||||||
@@ -1049,12 +1084,12 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
exports.all = all;
|
exports.all = all;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 15 */
|
/* 16 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/* global toString */
|
/* global toString */
|
||||||
var isArray = __webpack_require__(13).isArray;
|
var isArray = __webpack_require__(14).isArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`RSVP.race` allows you to watch a series of promises and act as soon as the
|
`RSVP.race` allows you to watch a series of promises and act as soon as the
|
||||||
@@ -1143,7 +1178,7 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
exports.race = race;
|
exports.race = race;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 16 */
|
/* 17 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -1163,7 +1198,7 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
exports.resolve = resolve;
|
exports.resolve = resolve;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 17 */
|
/* 18 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -1215,7 +1250,7 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
exports.reject = reject;
|
exports.reject = reject;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 18 */
|
/* 19 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
/* WEBPACK VAR INJECTION */(function(global, process) {"use strict";
|
/* WEBPACK VAR INJECTION */(function(global, process) {"use strict";
|
||||||
@@ -1279,10 +1314,10 @@ define("axios", [], function() { return /******/ (function(modules) { // webpack
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.asap = asap;
|
exports.asap = asap;
|
||||||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(19)))
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(20)))
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 19 */
|
/* 20 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
// shim for using process in browser
|
// shim for using process in browser
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+66
-31
@@ -51,7 +51,7 @@ var axios =
|
|||||||
/* 1 */
|
/* 1 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
var Promise = __webpack_require__(9).Promise;
|
var Promise = __webpack_require__(10).Promise;
|
||||||
var buildUrl = __webpack_require__(2);
|
var buildUrl = __webpack_require__(2);
|
||||||
var cookies = __webpack_require__(3);
|
var cookies = __webpack_require__(3);
|
||||||
var defaults = __webpack_require__(4);
|
var defaults = __webpack_require__(4);
|
||||||
@@ -59,6 +59,7 @@ var axios =
|
|||||||
var transformData = __webpack_require__(6);
|
var transformData = __webpack_require__(6);
|
||||||
var urlIsSameOrigin = __webpack_require__(7);
|
var urlIsSameOrigin = __webpack_require__(7);
|
||||||
var utils = __webpack_require__(8);
|
var utils = __webpack_require__(8);
|
||||||
|
var spread = __webpack_require__(9);
|
||||||
|
|
||||||
var axios = module.exports = function axios(config) {
|
var axios = module.exports = function axios(config) {
|
||||||
config = utils.merge({
|
config = utils.merge({
|
||||||
@@ -181,6 +182,10 @@ var axios =
|
|||||||
// Expose defaults
|
// Expose defaults
|
||||||
axios.defaults = defaults;
|
axios.defaults = defaults;
|
||||||
|
|
||||||
|
// Expose all/spread
|
||||||
|
axios.all = Promise.all;
|
||||||
|
axios.spread = spread;
|
||||||
|
|
||||||
// Provide aliases for supported request methods
|
// Provide aliases for supported request methods
|
||||||
createShortMethods('delete', 'get', 'head');
|
createShortMethods('delete', 'get', 'head');
|
||||||
createShortMethodsWithData('post', 'put', 'patch');
|
createShortMethodsWithData('post', 'put', 'patch');
|
||||||
@@ -638,27 +643,57 @@ var axios =
|
|||||||
/* 9 */
|
/* 9 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
var Promise = __webpack_require__(10).Promise;
|
* Syntactic sugar for invoking a function and expanding an array for arguments.
|
||||||
var polyfill = __webpack_require__(11).polyfill;
|
*
|
||||||
exports.Promise = Promise;
|
* Common use case would be to use `Function.prototype.apply`.
|
||||||
exports.polyfill = polyfill;
|
*
|
||||||
|
* ```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);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 10 */
|
/* 10 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
var config = __webpack_require__(12).config;
|
var Promise = __webpack_require__(11).Promise;
|
||||||
var configure = __webpack_require__(12).configure;
|
var polyfill = __webpack_require__(12).polyfill;
|
||||||
var objectOrFunction = __webpack_require__(13).objectOrFunction;
|
exports.Promise = Promise;
|
||||||
var isFunction = __webpack_require__(13).isFunction;
|
exports.polyfill = polyfill;
|
||||||
var now = __webpack_require__(13).now;
|
|
||||||
var all = __webpack_require__(14).all;
|
/***/ },
|
||||||
var race = __webpack_require__(15).race;
|
/* 11 */
|
||||||
var staticResolve = __webpack_require__(16).resolve;
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
var staticReject = __webpack_require__(17).reject;
|
|
||||||
var asap = __webpack_require__(18).asap;
|
"use strict";
|
||||||
|
var config = __webpack_require__(13).config;
|
||||||
|
var configure = __webpack_require__(13).configure;
|
||||||
|
var objectOrFunction = __webpack_require__(14).objectOrFunction;
|
||||||
|
var isFunction = __webpack_require__(14).isFunction;
|
||||||
|
var now = __webpack_require__(14).now;
|
||||||
|
var all = __webpack_require__(15).all;
|
||||||
|
var race = __webpack_require__(16).race;
|
||||||
|
var staticResolve = __webpack_require__(17).resolve;
|
||||||
|
var staticReject = __webpack_require__(18).reject;
|
||||||
|
var asap = __webpack_require__(19).asap;
|
||||||
|
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
|
|
||||||
@@ -861,13 +896,13 @@ var axios =
|
|||||||
exports.Promise = Promise;
|
exports.Promise = Promise;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 11 */
|
/* 12 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
/* WEBPACK VAR INJECTION */(function(global) {"use strict";
|
/* WEBPACK VAR INJECTION */(function(global) {"use strict";
|
||||||
/*global self*/
|
/*global self*/
|
||||||
var RSVPPromise = __webpack_require__(10).Promise;
|
var RSVPPromise = __webpack_require__(11).Promise;
|
||||||
var isFunction = __webpack_require__(13).isFunction;
|
var isFunction = __webpack_require__(14).isFunction;
|
||||||
|
|
||||||
function polyfill() {
|
function polyfill() {
|
||||||
var local;
|
var local;
|
||||||
@@ -905,7 +940,7 @@ var axios =
|
|||||||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 12 */
|
/* 13 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -925,7 +960,7 @@ var axios =
|
|||||||
exports.configure = configure;
|
exports.configure = configure;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 13 */
|
/* 14 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -952,14 +987,14 @@ var axios =
|
|||||||
exports.now = now;
|
exports.now = now;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 14 */
|
/* 15 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/* global toString */
|
/* global toString */
|
||||||
|
|
||||||
var isArray = __webpack_require__(13).isArray;
|
var isArray = __webpack_require__(14).isArray;
|
||||||
var isFunction = __webpack_require__(13).isFunction;
|
var isFunction = __webpack_require__(14).isFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a promise that is fulfilled when all the given promises have been
|
Returns a promise that is fulfilled when all the given promises have been
|
||||||
@@ -1050,12 +1085,12 @@ var axios =
|
|||||||
exports.all = all;
|
exports.all = all;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 15 */
|
/* 16 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
/* global toString */
|
/* global toString */
|
||||||
var isArray = __webpack_require__(13).isArray;
|
var isArray = __webpack_require__(14).isArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
`RSVP.race` allows you to watch a series of promises and act as soon as the
|
`RSVP.race` allows you to watch a series of promises and act as soon as the
|
||||||
@@ -1144,7 +1179,7 @@ var axios =
|
|||||||
exports.race = race;
|
exports.race = race;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 16 */
|
/* 17 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -1164,7 +1199,7 @@ var axios =
|
|||||||
exports.resolve = resolve;
|
exports.resolve = resolve;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 17 */
|
/* 18 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
@@ -1216,7 +1251,7 @@ var axios =
|
|||||||
exports.reject = reject;
|
exports.reject = reject;
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 18 */
|
/* 19 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
/* WEBPACK VAR INJECTION */(function(global, process) {"use strict";
|
/* WEBPACK VAR INJECTION */(function(global, process) {"use strict";
|
||||||
@@ -1280,10 +1315,10 @@ var axios =
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.asap = asap;
|
exports.asap = asap;
|
||||||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(19)))
|
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(20)))
|
||||||
|
|
||||||
/***/ },
|
/***/ },
|
||||||
/* 19 */
|
/* 20 */
|
||||||
/***/ function(module, exports, __webpack_require__) {
|
/***/ function(module, exports, __webpack_require__) {
|
||||||
|
|
||||||
// shim for using process in browser
|
// shim for using process in browser
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -6,6 +6,7 @@ var parseHeaders = require('./parseHeaders');
|
|||||||
var transformData = require('./transformData');
|
var transformData = require('./transformData');
|
||||||
var urlIsSameOrigin = require('./urlIsSameOrigin');
|
var urlIsSameOrigin = require('./urlIsSameOrigin');
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
|
var spread = require('./spread');
|
||||||
|
|
||||||
var axios = module.exports = function axios(config) {
|
var axios = module.exports = function axios(config) {
|
||||||
config = utils.merge({
|
config = utils.merge({
|
||||||
@@ -128,6 +129,10 @@ var axios = module.exports = function axios(config) {
|
|||||||
// Expose defaults
|
// Expose defaults
|
||||||
axios.defaults = defaults;
|
axios.defaults = defaults;
|
||||||
|
|
||||||
|
// Expose all/spread
|
||||||
|
axios.all = Promise.all;
|
||||||
|
axios.spread = spread;
|
||||||
|
|
||||||
// Provide aliases for supported request methods
|
// Provide aliases for supported request methods
|
||||||
createShortMethods('delete', 'get', 'head');
|
createShortMethods('delete', 'get', 'head');
|
||||||
createShortMethodsWithData('post', 'put', 'patch');
|
createShortMethodsWithData('post', 'put', 'patch');
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -22,6 +22,11 @@ describe('axios', function () {
|
|||||||
expect(typeof axios.defaults).toEqual('object');
|
expect(typeof axios.defaults).toEqual('object');
|
||||||
expect(typeof axios.defaults.headers).toEqual('object');
|
expect(typeof axios.defaults.headers).toEqual('object');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should have all/spread helpers', function () {
|
||||||
|
expect(typeof axios.all).toEqual('function');
|
||||||
|
expect(typeof axios.spread).toEqual('function');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('wrapper', function () {
|
describe('wrapper', function () {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
var spread = require('../../lib/spread');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
testSpread: function (test) {
|
||||||
|
var value = 0;
|
||||||
|
spread(function (a, b) {
|
||||||
|
value = a * b;
|
||||||
|
})([5, 10]);
|
||||||
|
|
||||||
|
test.equals(value, 50);
|
||||||
|
test.done();
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user