mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
Releasing 0.4.0
This commit is contained in:
+10
-1
@@ -25,4 +25,13 @@
|
||||
|
||||
### 0.3.1 (Sep 16, 2014)
|
||||
|
||||
- Fixing missing post body when using node.js ([#3](https://github.com/mzabriskie/axios/issues/3))
|
||||
- Fixing missing post body when using node.js ([#3](https://github.com/mzabriskie/axios/issues/3))
|
||||
|
||||
### 0.4.0 (Oct 03, 2014)
|
||||
|
||||
- Adding support for `ArrayBuffer` and `ArrayBufferView`
|
||||
- Adding support for utf-8 for node.js
|
||||
- Adding support for SSL for node.js ([#12](https://github.com/mzabriskie/axios/issues/12))
|
||||
- Fixing incorrect `Content-Type` header ([#9](https://github.com/mzabriskie/axios/issues/9))
|
||||
- Adding standalone build without bundled es6-promise ([#11](https://github.com/mzabriskie/axios/issues/11))
|
||||
- Deprecating `success`/`error` in favor of `then`/`catch`
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"main": "./dist/axios.js",
|
||||
"version": "0.3.1",
|
||||
"version": "0.4.0",
|
||||
"homepage": "https://github.com/mzabriskie/axios",
|
||||
"authors": [
|
||||
"Matt Zabriskie"
|
||||
@@ -27,7 +27,7 @@
|
||||
"node_modules",
|
||||
"sandbox",
|
||||
"test",
|
||||
"CONTRIBUTING.md",
|
||||
"CONTRIBUTING.md",
|
||||
"Gruntfile.js",
|
||||
"index.js",
|
||||
"karma.conf.js",
|
||||
|
||||
Vendored
+113
-45
@@ -53,11 +53,11 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
/* WEBPACK VAR INJECTION */(function(process) {var Promise = __webpack_require__(13).Promise;
|
||||
var defaults = __webpack_require__(3);
|
||||
var utils = __webpack_require__(4);
|
||||
var spread = __webpack_require__(5);
|
||||
|
||||
var axios = module.exports = function axios(config) {
|
||||
config = utils.merge({
|
||||
method: 'get',
|
||||
headers: {},
|
||||
transformRequest: defaults.transformRequest,
|
||||
transformResponse: defaults.transformResponse
|
||||
}, config);
|
||||
@@ -69,7 +69,7 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
try {
|
||||
// For browsers use XHR adapter
|
||||
if (typeof window !== 'undefined') {
|
||||
__webpack_require__(6)(resolve, reject, config);
|
||||
__webpack_require__(5)(resolve, reject, config);
|
||||
}
|
||||
// For node use HTTP adapter
|
||||
else if (typeof process !== 'undefined') {
|
||||
@@ -80,8 +80,23 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
}
|
||||
});
|
||||
|
||||
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) {}
|
||||
}
|
||||
|
||||
// Provide alias for success
|
||||
promise.success = function success(fn) {
|
||||
deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
||||
|
||||
promise.then(function(response) {
|
||||
fn(response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
@@ -90,6 +105,8 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
|
||||
// Provide alias for error
|
||||
promise.error = function error(fn) {
|
||||
deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
||||
|
||||
promise.then(null, function(response) {
|
||||
fn(response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
@@ -106,7 +123,7 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
axios.all = function (promises) {
|
||||
return Promise.all(promises);
|
||||
};
|
||||
axios.spread = spread;
|
||||
axios.spread = __webpack_require__(6);
|
||||
|
||||
// Provide aliases for supported request methods
|
||||
createShortMethods('delete', 'get', 'head');
|
||||
@@ -154,16 +171,26 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
var JSON_START = /^\s*(\[|\{[^\{])/;
|
||||
var JSON_END = /[\}\]]\s*$/;
|
||||
var PROTECTION_PREFIX = /^\)\]\}',?\n/;
|
||||
var CONTENT_TYPE_APPLICATION_JSON = {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
var DEFAULT_CONTENT_TYPE = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
transformRequest: [function (data) {
|
||||
return utils.isObject(data) &&
|
||||
!utils.isFile(data) &&
|
||||
!utils.isBlob(data) ?
|
||||
JSON.stringify(data) : data;
|
||||
transformRequest: [function (data, headers) {
|
||||
if (utils.isArrayBuffer(data)) {
|
||||
return data;
|
||||
}
|
||||
if (utils.isArrayBufferView(data)) {
|
||||
return data.buffer;
|
||||
}
|
||||
if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {
|
||||
// Set application/json if no Content-Type has been specified
|
||||
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
||||
headers['Content-Type'] = 'application/json;charset=utf-8';
|
||||
}
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
return data;
|
||||
}],
|
||||
|
||||
transformResponse: [function (data) {
|
||||
@@ -180,9 +207,9 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
common: {
|
||||
'Accept': 'application/json, text/plain, */*'
|
||||
},
|
||||
patch: utils.merge(CONTENT_TYPE_APPLICATION_JSON),
|
||||
post: utils.merge(CONTENT_TYPE_APPLICATION_JSON),
|
||||
put: utils.merge(CONTENT_TYPE_APPLICATION_JSON)
|
||||
patch: utils.merge(DEFAULT_CONTENT_TYPE),
|
||||
post: utils.merge(DEFAULT_CONTENT_TYPE),
|
||||
put: utils.merge(DEFAULT_CONTENT_TYPE)
|
||||
},
|
||||
|
||||
xsrfCookieName: 'XSRF-TOKEN',
|
||||
@@ -207,6 +234,30 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
return toString.call(val) === '[object Array]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an ArrayBuffer
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
||||
*/
|
||||
function isArrayBuffer(val) {
|
||||
return toString.call(val) === '[object ArrayBuffer]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a view on an ArrayBuffer
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
||||
*/
|
||||
function isArrayBufferView(val) {
|
||||
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
||||
return ArrayBuffer.isView(val);
|
||||
} else {
|
||||
return (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a String
|
||||
*
|
||||
@@ -227,6 +278,16 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
return typeof val === 'number';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is undefined
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if the value is undefined, otherwise false
|
||||
*/
|
||||
function isUndefined(val) {
|
||||
return typeof val === 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an Object
|
||||
*
|
||||
@@ -348,9 +409,12 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
|
||||
module.exports = {
|
||||
isArray: isArray,
|
||||
isArrayBuffer: isArrayBuffer,
|
||||
isArrayBufferView: isArrayBufferView,
|
||||
isString: isString,
|
||||
isNumber: isNumber,
|
||||
isObject: isObject,
|
||||
isUndefined: isUndefined,
|
||||
isDate: isDate,
|
||||
isFile: isFile,
|
||||
isBlob: isBlob,
|
||||
@@ -363,43 +427,13 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
/* 5 */
|
||||
/***/ 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);
|
||||
};
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var defaults = __webpack_require__(3);
|
||||
var utils = __webpack_require__(4);
|
||||
var buildUrl = __webpack_require__(8);
|
||||
var cookies = __webpack_require__(9);
|
||||
var defaults = __webpack_require__(3);
|
||||
var parseHeaders = __webpack_require__(10);
|
||||
var transformData = __webpack_require__(11);
|
||||
var urlIsSameOrigin = __webpack_require__(12);
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
module.exports = function xhrAdapter(resolve, reject, config) {
|
||||
// Transform request data
|
||||
@@ -482,10 +516,44 @@ define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(data)) {
|
||||
data = new DataView(data);
|
||||
}
|
||||
|
||||
// Send the request
|
||||
request.send(data);
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ 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);
|
||||
};
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 7 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
-2
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
+837
@@ -0,0 +1,837 @@
|
||||
define("axios", ["undefined"], function(__WEBPACK_EXTERNAL_MODULE_2__) { return /******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(0);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(1);
|
||||
|
||||
/***/ },
|
||||
/* 1 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(process) {var Promise = __webpack_require__(2).Promise;
|
||||
var defaults = __webpack_require__(3);
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
var axios = module.exports = function axios(config) {
|
||||
config = utils.merge({
|
||||
method: 'get',
|
||||
headers: {},
|
||||
transformRequest: defaults.transformRequest,
|
||||
transformResponse: defaults.transformResponse
|
||||
}, config);
|
||||
|
||||
// Don't allow overriding defaults.withCredentials
|
||||
config.withCredentials = config.withCredentials || defaults.withCredentials;
|
||||
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
try {
|
||||
// For browsers use XHR adapter
|
||||
if (typeof window !== 'undefined') {
|
||||
__webpack_require__(5)(resolve, reject, config);
|
||||
}
|
||||
// For node use HTTP adapter
|
||||
else if (typeof process !== 'undefined') {
|
||||
__webpack_require__(2)(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) {}
|
||||
}
|
||||
|
||||
// Provide alias for success
|
||||
promise.success = function success(fn) {
|
||||
deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
||||
|
||||
promise.then(function(response) {
|
||||
fn(response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
return promise;
|
||||
};
|
||||
|
||||
// Provide alias for error
|
||||
promise.error = function error(fn) {
|
||||
deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
||||
|
||||
promise.then(null, function(response) {
|
||||
fn(response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
return promise;
|
||||
};
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
// Expose defaults
|
||||
axios.defaults = defaults;
|
||||
|
||||
// Expose all/spread
|
||||
axios.all = function (promises) {
|
||||
return Promise.all(promises);
|
||||
};
|
||||
axios.spread = __webpack_require__(6);
|
||||
|
||||
// Provide aliases for supported request methods
|
||||
createShortMethods('delete', 'get', 'head');
|
||||
createShortMethodsWithData('post', 'put', 'patch');
|
||||
|
||||
function createShortMethods() {
|
||||
utils.forEach(arguments, function (method) {
|
||||
axios[method] = function (url, config) {
|
||||
return axios(utils.merge(config || {}, {
|
||||
method: method,
|
||||
url: url
|
||||
}));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createShortMethodsWithData() {
|
||||
utils.forEach(arguments, function (method) {
|
||||
axios[method] = function (url, data, config) {
|
||||
return axios(utils.merge(config || {}, {
|
||||
method: method,
|
||||
url: url,
|
||||
data: data
|
||||
}));
|
||||
};
|
||||
});
|
||||
}
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7)))
|
||||
|
||||
/***/ },
|
||||
/* 2 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = undefined;
|
||||
|
||||
/***/ },
|
||||
/* 3 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
var JSON_START = /^\s*(\[|\{[^\{])/;
|
||||
var JSON_END = /[\}\]]\s*$/;
|
||||
var PROTECTION_PREFIX = /^\)\]\}',?\n/;
|
||||
var DEFAULT_CONTENT_TYPE = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
transformRequest: [function (data, headers) {
|
||||
if (utils.isArrayBuffer(data)) {
|
||||
return data;
|
||||
}
|
||||
if (utils.isArrayBufferView(data)) {
|
||||
return data.buffer;
|
||||
}
|
||||
if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {
|
||||
// Set application/json if no Content-Type has been specified
|
||||
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
||||
headers['Content-Type'] = 'application/json;charset=utf-8';
|
||||
}
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
return data;
|
||||
}],
|
||||
|
||||
transformResponse: [function (data) {
|
||||
if (typeof data === 'string') {
|
||||
data = data.replace(PROTECTION_PREFIX, '');
|
||||
if (JSON_START.test(data) && JSON_END.test(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}],
|
||||
|
||||
headers: {
|
||||
common: {
|
||||
'Accept': 'application/json, text/plain, */*'
|
||||
},
|
||||
patch: utils.merge(DEFAULT_CONTENT_TYPE),
|
||||
post: utils.merge(DEFAULT_CONTENT_TYPE),
|
||||
put: utils.merge(DEFAULT_CONTENT_TYPE)
|
||||
},
|
||||
|
||||
xsrfCookieName: 'XSRF-TOKEN',
|
||||
xsrfHeaderName: 'X-XSRF-TOKEN'
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 4 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
// utils is a library of generic helper functions non-specific to axios
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Determine if a value is an Array
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an Array, otherwise false
|
||||
*/
|
||||
function isArray(val) {
|
||||
return toString.call(val) === '[object Array]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an ArrayBuffer
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
||||
*/
|
||||
function isArrayBuffer(val) {
|
||||
return toString.call(val) === '[object ArrayBuffer]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a view on an ArrayBuffer
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
||||
*/
|
||||
function isArrayBufferView(val) {
|
||||
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
||||
return ArrayBuffer.isView(val);
|
||||
} else {
|
||||
return (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a String
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a String, otherwise false
|
||||
*/
|
||||
function isString(val) {
|
||||
return typeof val === 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a Number
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a Number, otherwise false
|
||||
*/
|
||||
function isNumber(val) {
|
||||
return typeof val === 'number';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is undefined
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if the value is undefined, otherwise false
|
||||
*/
|
||||
function isUndefined(val) {
|
||||
return typeof val === 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an Object
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an Object, otherwise false
|
||||
*/
|
||||
function isObject(val) {
|
||||
return val !== null && typeof val === 'object';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a Date
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a Date, otherwise false
|
||||
*/
|
||||
function isDate(val) {
|
||||
return toString.call(val) === '[object Date]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a File
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a File, otherwise false
|
||||
*/
|
||||
function isFile(val) {
|
||||
return toString.call(val) === '[object File]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a Blob
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a Blob, otherwise false
|
||||
*/
|
||||
function isBlob(val) {
|
||||
return toString.call(val) === '[object Blob]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim excess whitespace off the beginning and end of a string
|
||||
*
|
||||
* @param {String} str The String to trim
|
||||
* @returns {String} The String freed of excess whitespace
|
||||
*/
|
||||
function trim(str) {
|
||||
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over an Array or an Object invoking a function for each item.
|
||||
*
|
||||
* If `obj` is an Array or arguments callback will be called passing
|
||||
* the value, index, and complete array for each item.
|
||||
*
|
||||
* If 'obj' is an Object callback will be called passing
|
||||
* the value, key, and complete object for each property.
|
||||
*
|
||||
* @param {Object|Array} obj The object to iterate
|
||||
* @param {Function} fn The callback to invoke for each item
|
||||
*/
|
||||
function forEach(obj, fn) {
|
||||
// Don't bother if no value provided
|
||||
if (obj === null || typeof obj === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if obj is array-like
|
||||
var isArray = obj.constructor === Array || typeof obj.callee === 'function';
|
||||
|
||||
// Force an array if not already something iterable
|
||||
if (typeof obj !== 'object' && !isArray) {
|
||||
obj = [obj];
|
||||
}
|
||||
|
||||
// Iterate over array values
|
||||
if (isArray) {
|
||||
for (var i=0, l=obj.length; i<l; i++) {
|
||||
fn.call(null, obj[i], i, obj);
|
||||
}
|
||||
}
|
||||
// Iterate over object keys
|
||||
else {
|
||||
for (var key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
fn.call(null, obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts varargs expecting each argument to be an object, then
|
||||
* immutably merges the properties of each object and returns result.
|
||||
*
|
||||
* When multiple objects contain the same key the later object in
|
||||
* the arguments list will take precedence.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* var result = merge({foo: 123}, {foo: 456});
|
||||
* console.log(result.foo); // outputs 456
|
||||
* ```
|
||||
*
|
||||
* @param {Object} obj1 Object to merge
|
||||
* @returns {Object} Result of all merge properties
|
||||
*/
|
||||
function merge(obj1/*, obj2, obj3, ...*/) {
|
||||
var result = {};
|
||||
forEach(arguments, function (obj) {
|
||||
forEach(obj, function (val, key) {
|
||||
result[key] = val;
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isArray: isArray,
|
||||
isArrayBuffer: isArrayBuffer,
|
||||
isArrayBufferView: isArrayBufferView,
|
||||
isString: isString,
|
||||
isNumber: isNumber,
|
||||
isObject: isObject,
|
||||
isUndefined: isUndefined,
|
||||
isDate: isDate,
|
||||
isFile: isFile,
|
||||
isBlob: isBlob,
|
||||
forEach: forEach,
|
||||
merge: merge,
|
||||
trim: trim
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 5 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var defaults = __webpack_require__(3);
|
||||
var utils = __webpack_require__(4);
|
||||
var buildUrl = __webpack_require__(8);
|
||||
var cookies = __webpack_require__(9);
|
||||
var parseHeaders = __webpack_require__(10);
|
||||
var transformData = __webpack_require__(11);
|
||||
var urlIsSameOrigin = __webpack_require__(12);
|
||||
|
||||
module.exports = function xhrAdapter(resolve, reject, config) {
|
||||
// Transform request data
|
||||
var data = transformData(
|
||||
config.data,
|
||||
config.headers,
|
||||
config.transformRequest
|
||||
);
|
||||
|
||||
// Merge headers
|
||||
var headers = utils.merge(
|
||||
defaults.headers.common,
|
||||
defaults.headers[config.method] || {},
|
||||
config.headers || {}
|
||||
);
|
||||
|
||||
// Create the request
|
||||
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
||||
request.open(config.method, buildUrl(config.url, config.params), true);
|
||||
|
||||
// Listen for ready state
|
||||
request.onreadystatechange = function () {
|
||||
if (request && request.readyState === 4) {
|
||||
// Prepare the response
|
||||
var headers = parseHeaders(request.getAllResponseHeaders());
|
||||
var response = {
|
||||
data: transformData(
|
||||
request.responseText,
|
||||
headers,
|
||||
config.transformResponse
|
||||
),
|
||||
status: request.status,
|
||||
headers: headers,
|
||||
config: config
|
||||
};
|
||||
|
||||
// Resolve or reject the Promise based on the status
|
||||
(request.status >= 200 && request.status < 300
|
||||
? resolve
|
||||
: reject)(response);
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
}
|
||||
};
|
||||
|
||||
// Add xsrf header
|
||||
var xsrfValue = urlIsSameOrigin(config.url)
|
||||
? cookies.read(config.xsrfCookieName || defaults.xsrfCookieName)
|
||||
: undefined;
|
||||
if (xsrfValue) {
|
||||
headers[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
|
||||
}
|
||||
|
||||
// Add headers to the request
|
||||
utils.forEach(headers, function (val, key) {
|
||||
// Remove Content-Type if data is undefined
|
||||
if (!data && key.toLowerCase() === 'content-type') {
|
||||
delete headers[key];
|
||||
}
|
||||
// Otherwise add header to the request
|
||||
else {
|
||||
request.setRequestHeader(key, val);
|
||||
}
|
||||
});
|
||||
|
||||
// Add withCredentials to request if needed
|
||||
if (config.withCredentials) {
|
||||
request.withCredentials = true;
|
||||
}
|
||||
|
||||
// Add responseType to request if needed
|
||||
if (config.responseType) {
|
||||
try {
|
||||
request.responseType = config.responseType;
|
||||
} catch (e) {
|
||||
if (request.responseType !== 'json') {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(data)) {
|
||||
data = new DataView(data);
|
||||
}
|
||||
|
||||
// Send the request
|
||||
request.send(data);
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ 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);
|
||||
};
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 7 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
// shim for using process in browser
|
||||
|
||||
var process = module.exports = {};
|
||||
|
||||
process.nextTick = (function () {
|
||||
var canSetImmediate = typeof window !== 'undefined'
|
||||
&& window.setImmediate;
|
||||
var canPost = typeof window !== 'undefined'
|
||||
&& window.postMessage && window.addEventListener
|
||||
;
|
||||
|
||||
if (canSetImmediate) {
|
||||
return function (f) { return window.setImmediate(f) };
|
||||
}
|
||||
|
||||
if (canPost) {
|
||||
var queue = [];
|
||||
window.addEventListener('message', function (ev) {
|
||||
var source = ev.source;
|
||||
if ((source === window || source === null) && ev.data === 'process-tick') {
|
||||
ev.stopPropagation();
|
||||
if (queue.length > 0) {
|
||||
var fn = queue.shift();
|
||||
fn();
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
||||
return function nextTick(fn) {
|
||||
queue.push(fn);
|
||||
window.postMessage('process-tick', '*');
|
||||
};
|
||||
}
|
||||
|
||||
return function nextTick(fn) {
|
||||
setTimeout(fn, 0);
|
||||
};
|
||||
})();
|
||||
|
||||
process.title = 'browser';
|
||||
process.browser = true;
|
||||
process.env = {};
|
||||
process.argv = [];
|
||||
|
||||
function noop() {}
|
||||
|
||||
process.on = noop;
|
||||
process.addListener = noop;
|
||||
process.once = noop;
|
||||
process.off = noop;
|
||||
process.removeListener = noop;
|
||||
process.removeAllListeners = noop;
|
||||
process.emit = noop;
|
||||
|
||||
process.binding = function (name) {
|
||||
throw new Error('process.binding is not supported');
|
||||
}
|
||||
|
||||
// TODO(shtylman)
|
||||
process.cwd = function () { return '/' };
|
||||
process.chdir = function (dir) {
|
||||
throw new Error('process.chdir is not supported');
|
||||
};
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 8 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
function encode(val) {
|
||||
return encodeURIComponent(val).
|
||||
replace(/%40/gi, '@').
|
||||
replace(/%3A/gi, ':').
|
||||
replace(/%24/g, '$').
|
||||
replace(/%2C/gi, ',').
|
||||
replace(/%20/g, '+');
|
||||
}
|
||||
|
||||
module.exports = function buildUrl(url, params) {
|
||||
if (!params) {
|
||||
return url;
|
||||
}
|
||||
|
||||
var parts = [];
|
||||
|
||||
utils.forEach(params, function (val, key) {
|
||||
if (val === null || typeof val === 'undefined') {
|
||||
return;
|
||||
}
|
||||
if (!utils.isArray(val)) {
|
||||
val = [val];
|
||||
}
|
||||
|
||||
utils.forEach(val, function (v) {
|
||||
if (utils.isDate(v)) {
|
||||
v = v.toISOString();
|
||||
}
|
||||
else if (utils.isObject(v)) {
|
||||
v = JSON.stringify(v);
|
||||
}
|
||||
parts.push(encode(key) + '=' + encode(v));
|
||||
});
|
||||
});
|
||||
|
||||
if (parts.length > 0) {
|
||||
url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&');
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 9 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
module.exports = {
|
||||
write: function write(name, value, expires, path, domain, secure) {
|
||||
var cookie = [];
|
||||
cookie.push(name + '=' + encodeURIComponent(value));
|
||||
|
||||
if (utils.isNumber(expires)) {
|
||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||
}
|
||||
|
||||
if (utils.isString(path)) {
|
||||
cookie.push('path=' + path);
|
||||
}
|
||||
|
||||
if (utils.isString(domain)) {
|
||||
cookie.push('domain=' + domain);
|
||||
}
|
||||
|
||||
if (secure === true) {
|
||||
cookie.push('secure');
|
||||
}
|
||||
|
||||
document.cookie = cookie.join('; ');
|
||||
},
|
||||
|
||||
read: function read(name) {
|
||||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||||
return (match ? decodeURIComponent(match[3]) : null);
|
||||
},
|
||||
|
||||
remove: function remove(name) {
|
||||
this.write(name, '', Date.now() - 86400000);
|
||||
}
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 10 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
/**
|
||||
* Parse headers into an object
|
||||
*
|
||||
* ```
|
||||
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
||||
* Content-Type: application/json
|
||||
* Connection: keep-alive
|
||||
* Transfer-Encoding: chunked
|
||||
* ```
|
||||
*
|
||||
* @param {String} headers Headers needing to be parsed
|
||||
* @returns {Object} Headers parsed into an object
|
||||
*/
|
||||
module.exports = function parseHeaders(headers) {
|
||||
var parsed = {}, key, val, i;
|
||||
|
||||
if (!headers) return parsed;
|
||||
|
||||
utils.forEach(headers.split('\n'), function(line) {
|
||||
i = line.indexOf(':');
|
||||
key = utils.trim(line.substr(0, i)).toLowerCase();
|
||||
val = utils.trim(line.substr(i + 1));
|
||||
|
||||
if (key) {
|
||||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
||||
}
|
||||
});
|
||||
|
||||
return parsed;
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 11 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
/**
|
||||
* Transform the data for a request or a response
|
||||
*
|
||||
* @param {Object|String} data The data to be transformed
|
||||
* @param {Array} headers The headers for the request or response
|
||||
* @param {Array|Function} fns A single function or Array of functions
|
||||
* @returns {*} The resulting transformed data
|
||||
*/
|
||||
module.exports = function transformData(data, headers, fns) {
|
||||
utils.forEach(fns, function (fn) {
|
||||
data = fn(data, headers);
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 12 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
||||
var utils = __webpack_require__(4);
|
||||
var urlParsingNode = document.createElement('a');
|
||||
var originUrl = urlResolve(window.location.href);
|
||||
|
||||
/**
|
||||
* Parse a URL to discover it's components
|
||||
*
|
||||
* @param {String} url The URL to be parsed
|
||||
* @returns {Object}
|
||||
*/
|
||||
function urlResolve(url) {
|
||||
var href = url;
|
||||
|
||||
if (msie) {
|
||||
// IE needs attribute set twice to normalize properties
|
||||
urlParsingNode.setAttribute('href', href);
|
||||
href = urlParsingNode.href;
|
||||
}
|
||||
|
||||
urlParsingNode.setAttribute('href', href);
|
||||
|
||||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||||
return {
|
||||
href: urlParsingNode.href,
|
||||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||||
host: urlParsingNode.host,
|
||||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||||
hostname: urlParsingNode.hostname,
|
||||
port: urlParsingNode.port,
|
||||
pathname: (urlParsingNode.pathname.charAt(0) === '/')
|
||||
? urlParsingNode.pathname
|
||||
: '/' + urlParsingNode.pathname
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a URL shares the same origin as the current location
|
||||
*
|
||||
* @param {String} requestUrl The URL to test
|
||||
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||||
*/
|
||||
module.exports = function urlIsSameOrigin(requestUrl) {
|
||||
var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;
|
||||
return (parsed.protocol === originUrl.protocol &&
|
||||
parsed.host === originUrl.host);
|
||||
};
|
||||
|
||||
/***/ }
|
||||
/******/ ])});
|
||||
//# sourceMappingURL=axios.amd.standalone.map
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+3
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+73
-41
@@ -54,11 +54,11 @@ var axios =
|
||||
/* WEBPACK VAR INJECTION */(function(process) {var Promise = __webpack_require__(13).Promise;
|
||||
var defaults = __webpack_require__(3);
|
||||
var utils = __webpack_require__(4);
|
||||
var spread = __webpack_require__(5);
|
||||
|
||||
var axios = module.exports = function axios(config) {
|
||||
config = utils.merge({
|
||||
method: 'get',
|
||||
headers: {},
|
||||
transformRequest: defaults.transformRequest,
|
||||
transformResponse: defaults.transformResponse
|
||||
}, config);
|
||||
@@ -70,7 +70,7 @@ var axios =
|
||||
try {
|
||||
// For browsers use XHR adapter
|
||||
if (typeof window !== 'undefined') {
|
||||
__webpack_require__(6)(resolve, reject, config);
|
||||
__webpack_require__(5)(resolve, reject, config);
|
||||
}
|
||||
// For node use HTTP adapter
|
||||
else if (typeof process !== 'undefined') {
|
||||
@@ -81,8 +81,23 @@ var axios =
|
||||
}
|
||||
});
|
||||
|
||||
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) {}
|
||||
}
|
||||
|
||||
// Provide alias for success
|
||||
promise.success = function success(fn) {
|
||||
deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
||||
|
||||
promise.then(function(response) {
|
||||
fn(response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
@@ -91,6 +106,8 @@ var axios =
|
||||
|
||||
// Provide alias for error
|
||||
promise.error = function error(fn) {
|
||||
deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
||||
|
||||
promise.then(null, function(response) {
|
||||
fn(response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
@@ -107,7 +124,7 @@ var axios =
|
||||
axios.all = function (promises) {
|
||||
return Promise.all(promises);
|
||||
};
|
||||
axios.spread = spread;
|
||||
axios.spread = __webpack_require__(6);
|
||||
|
||||
// Provide aliases for supported request methods
|
||||
createShortMethods('delete', 'get', 'head');
|
||||
@@ -155,12 +172,12 @@ var axios =
|
||||
var JSON_START = /^\s*(\[|\{[^\{])/;
|
||||
var JSON_END = /[\}\]]\s*$/;
|
||||
var PROTECTION_PREFIX = /^\)\]\}',?\n/;
|
||||
var CONTENT_TYPE_APPLICATION_JSON = {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
var DEFAULT_CONTENT_TYPE = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
transformRequest: [function (data) {
|
||||
transformRequest: [function (data, headers) {
|
||||
if (utils.isArrayBuffer(data)) {
|
||||
return data;
|
||||
}
|
||||
@@ -168,6 +185,10 @@ var axios =
|
||||
return data.buffer;
|
||||
}
|
||||
if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {
|
||||
// Set application/json if no Content-Type has been specified
|
||||
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
||||
headers['Content-Type'] = 'application/json;charset=utf-8';
|
||||
}
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
return data;
|
||||
@@ -187,9 +208,9 @@ var axios =
|
||||
common: {
|
||||
'Accept': 'application/json, text/plain, */*'
|
||||
},
|
||||
patch: utils.merge(CONTENT_TYPE_APPLICATION_JSON),
|
||||
post: utils.merge(CONTENT_TYPE_APPLICATION_JSON),
|
||||
put: utils.merge(CONTENT_TYPE_APPLICATION_JSON)
|
||||
patch: utils.merge(DEFAULT_CONTENT_TYPE),
|
||||
post: utils.merge(DEFAULT_CONTENT_TYPE),
|
||||
put: utils.merge(DEFAULT_CONTENT_TYPE)
|
||||
},
|
||||
|
||||
xsrfCookieName: 'XSRF-TOKEN',
|
||||
@@ -258,6 +279,16 @@ var axios =
|
||||
return typeof val === 'number';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is undefined
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if the value is undefined, otherwise false
|
||||
*/
|
||||
function isUndefined(val) {
|
||||
return typeof val === 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an Object
|
||||
*
|
||||
@@ -384,6 +415,7 @@ var axios =
|
||||
isString: isString,
|
||||
isNumber: isNumber,
|
||||
isObject: isObject,
|
||||
isUndefined: isUndefined,
|
||||
isDate: isDate,
|
||||
isFile: isFile,
|
||||
isBlob: isBlob,
|
||||
@@ -396,43 +428,13 @@ var axios =
|
||||
/* 5 */
|
||||
/***/ 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);
|
||||
};
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var defaults = __webpack_require__(3);
|
||||
var utils = __webpack_require__(4);
|
||||
var buildUrl = __webpack_require__(8);
|
||||
var cookies = __webpack_require__(9);
|
||||
var defaults = __webpack_require__(3);
|
||||
var parseHeaders = __webpack_require__(10);
|
||||
var transformData = __webpack_require__(11);
|
||||
var urlIsSameOrigin = __webpack_require__(12);
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
module.exports = function xhrAdapter(resolve, reject, config) {
|
||||
// Transform request data
|
||||
@@ -523,6 +525,36 @@ var axios =
|
||||
request.send(data);
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ 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);
|
||||
};
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 7 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+2
-2
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
+838
@@ -0,0 +1,838 @@
|
||||
var axios =
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId])
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ exports: {},
|
||||
/******/ id: moduleId,
|
||||
/******/ loaded: false
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.loaded = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(0);
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ([
|
||||
/* 0 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = __webpack_require__(1);
|
||||
|
||||
/***/ },
|
||||
/* 1 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
/* WEBPACK VAR INJECTION */(function(process) {var Promise = __webpack_require__(2).Promise;
|
||||
var defaults = __webpack_require__(3);
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
var axios = module.exports = function axios(config) {
|
||||
config = utils.merge({
|
||||
method: 'get',
|
||||
headers: {},
|
||||
transformRequest: defaults.transformRequest,
|
||||
transformResponse: defaults.transformResponse
|
||||
}, config);
|
||||
|
||||
// Don't allow overriding defaults.withCredentials
|
||||
config.withCredentials = config.withCredentials || defaults.withCredentials;
|
||||
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
try {
|
||||
// For browsers use XHR adapter
|
||||
if (typeof window !== 'undefined') {
|
||||
__webpack_require__(5)(resolve, reject, config);
|
||||
}
|
||||
// For node use HTTP adapter
|
||||
else if (typeof process !== 'undefined') {
|
||||
__webpack_require__(2)(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) {}
|
||||
}
|
||||
|
||||
// Provide alias for success
|
||||
promise.success = function success(fn) {
|
||||
deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
||||
|
||||
promise.then(function(response) {
|
||||
fn(response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
return promise;
|
||||
};
|
||||
|
||||
// Provide alias for error
|
||||
promise.error = function error(fn) {
|
||||
deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
||||
|
||||
promise.then(null, function(response) {
|
||||
fn(response.data, response.status, response.headers, response.config);
|
||||
});
|
||||
return promise;
|
||||
};
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
// Expose defaults
|
||||
axios.defaults = defaults;
|
||||
|
||||
// Expose all/spread
|
||||
axios.all = function (promises) {
|
||||
return Promise.all(promises);
|
||||
};
|
||||
axios.spread = __webpack_require__(6);
|
||||
|
||||
// Provide aliases for supported request methods
|
||||
createShortMethods('delete', 'get', 'head');
|
||||
createShortMethodsWithData('post', 'put', 'patch');
|
||||
|
||||
function createShortMethods() {
|
||||
utils.forEach(arguments, function (method) {
|
||||
axios[method] = function (url, config) {
|
||||
return axios(utils.merge(config || {}, {
|
||||
method: method,
|
||||
url: url
|
||||
}));
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function createShortMethodsWithData() {
|
||||
utils.forEach(arguments, function (method) {
|
||||
axios[method] = function (url, data, config) {
|
||||
return axios(utils.merge(config || {}, {
|
||||
method: method,
|
||||
url: url,
|
||||
data: data
|
||||
}));
|
||||
};
|
||||
});
|
||||
}
|
||||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7)))
|
||||
|
||||
/***/ },
|
||||
/* 2 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
module.exports = undefined;
|
||||
|
||||
/***/ },
|
||||
/* 3 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
var JSON_START = /^\s*(\[|\{[^\{])/;
|
||||
var JSON_END = /[\}\]]\s*$/;
|
||||
var PROTECTION_PREFIX = /^\)\]\}',?\n/;
|
||||
var DEFAULT_CONTENT_TYPE = {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
transformRequest: [function (data, headers) {
|
||||
if (utils.isArrayBuffer(data)) {
|
||||
return data;
|
||||
}
|
||||
if (utils.isArrayBufferView(data)) {
|
||||
return data.buffer;
|
||||
}
|
||||
if (utils.isObject(data) && !utils.isFile(data) && !utils.isBlob(data)) {
|
||||
// Set application/json if no Content-Type has been specified
|
||||
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
||||
headers['Content-Type'] = 'application/json;charset=utf-8';
|
||||
}
|
||||
return JSON.stringify(data);
|
||||
}
|
||||
return data;
|
||||
}],
|
||||
|
||||
transformResponse: [function (data) {
|
||||
if (typeof data === 'string') {
|
||||
data = data.replace(PROTECTION_PREFIX, '');
|
||||
if (JSON_START.test(data) && JSON_END.test(data)) {
|
||||
data = JSON.parse(data);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}],
|
||||
|
||||
headers: {
|
||||
common: {
|
||||
'Accept': 'application/json, text/plain, */*'
|
||||
},
|
||||
patch: utils.merge(DEFAULT_CONTENT_TYPE),
|
||||
post: utils.merge(DEFAULT_CONTENT_TYPE),
|
||||
put: utils.merge(DEFAULT_CONTENT_TYPE)
|
||||
},
|
||||
|
||||
xsrfCookieName: 'XSRF-TOKEN',
|
||||
xsrfHeaderName: 'X-XSRF-TOKEN'
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 4 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
// utils is a library of generic helper functions non-specific to axios
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* Determine if a value is an Array
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an Array, otherwise false
|
||||
*/
|
||||
function isArray(val) {
|
||||
return toString.call(val) === '[object Array]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an ArrayBuffer
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an ArrayBuffer, otherwise false
|
||||
*/
|
||||
function isArrayBuffer(val) {
|
||||
return toString.call(val) === '[object ArrayBuffer]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a view on an ArrayBuffer
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
|
||||
*/
|
||||
function isArrayBufferView(val) {
|
||||
if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
|
||||
return ArrayBuffer.isView(val);
|
||||
} else {
|
||||
return (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a String
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a String, otherwise false
|
||||
*/
|
||||
function isString(val) {
|
||||
return typeof val === 'string';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a Number
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a Number, otherwise false
|
||||
*/
|
||||
function isNumber(val) {
|
||||
return typeof val === 'number';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is undefined
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if the value is undefined, otherwise false
|
||||
*/
|
||||
function isUndefined(val) {
|
||||
return typeof val === 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is an Object
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is an Object, otherwise false
|
||||
*/
|
||||
function isObject(val) {
|
||||
return val !== null && typeof val === 'object';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a Date
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a Date, otherwise false
|
||||
*/
|
||||
function isDate(val) {
|
||||
return toString.call(val) === '[object Date]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a File
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a File, otherwise false
|
||||
*/
|
||||
function isFile(val) {
|
||||
return toString.call(val) === '[object File]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a value is a Blob
|
||||
*
|
||||
* @param {Object} val The value to test
|
||||
* @returns {boolean} True if value is a Blob, otherwise false
|
||||
*/
|
||||
function isBlob(val) {
|
||||
return toString.call(val) === '[object Blob]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim excess whitespace off the beginning and end of a string
|
||||
*
|
||||
* @param {String} str The String to trim
|
||||
* @returns {String} The String freed of excess whitespace
|
||||
*/
|
||||
function trim(str) {
|
||||
return str.replace(/^\s*/, '').replace(/\s*$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate over an Array or an Object invoking a function for each item.
|
||||
*
|
||||
* If `obj` is an Array or arguments callback will be called passing
|
||||
* the value, index, and complete array for each item.
|
||||
*
|
||||
* If 'obj' is an Object callback will be called passing
|
||||
* the value, key, and complete object for each property.
|
||||
*
|
||||
* @param {Object|Array} obj The object to iterate
|
||||
* @param {Function} fn The callback to invoke for each item
|
||||
*/
|
||||
function forEach(obj, fn) {
|
||||
// Don't bother if no value provided
|
||||
if (obj === null || typeof obj === 'undefined') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if obj is array-like
|
||||
var isArray = obj.constructor === Array || typeof obj.callee === 'function';
|
||||
|
||||
// Force an array if not already something iterable
|
||||
if (typeof obj !== 'object' && !isArray) {
|
||||
obj = [obj];
|
||||
}
|
||||
|
||||
// Iterate over array values
|
||||
if (isArray) {
|
||||
for (var i=0, l=obj.length; i<l; i++) {
|
||||
fn.call(null, obj[i], i, obj);
|
||||
}
|
||||
}
|
||||
// Iterate over object keys
|
||||
else {
|
||||
for (var key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
fn.call(null, obj[key], key, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts varargs expecting each argument to be an object, then
|
||||
* immutably merges the properties of each object and returns result.
|
||||
*
|
||||
* When multiple objects contain the same key the later object in
|
||||
* the arguments list will take precedence.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```js
|
||||
* var result = merge({foo: 123}, {foo: 456});
|
||||
* console.log(result.foo); // outputs 456
|
||||
* ```
|
||||
*
|
||||
* @param {Object} obj1 Object to merge
|
||||
* @returns {Object} Result of all merge properties
|
||||
*/
|
||||
function merge(obj1/*, obj2, obj3, ...*/) {
|
||||
var result = {};
|
||||
forEach(arguments, function (obj) {
|
||||
forEach(obj, function (val, key) {
|
||||
result[key] = val;
|
||||
});
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isArray: isArray,
|
||||
isArrayBuffer: isArrayBuffer,
|
||||
isArrayBufferView: isArrayBufferView,
|
||||
isString: isString,
|
||||
isNumber: isNumber,
|
||||
isObject: isObject,
|
||||
isUndefined: isUndefined,
|
||||
isDate: isDate,
|
||||
isFile: isFile,
|
||||
isBlob: isBlob,
|
||||
forEach: forEach,
|
||||
merge: merge,
|
||||
trim: trim
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 5 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
var defaults = __webpack_require__(3);
|
||||
var utils = __webpack_require__(4);
|
||||
var buildUrl = __webpack_require__(8);
|
||||
var cookies = __webpack_require__(9);
|
||||
var parseHeaders = __webpack_require__(10);
|
||||
var transformData = __webpack_require__(11);
|
||||
var urlIsSameOrigin = __webpack_require__(12);
|
||||
|
||||
module.exports = function xhrAdapter(resolve, reject, config) {
|
||||
// Transform request data
|
||||
var data = transformData(
|
||||
config.data,
|
||||
config.headers,
|
||||
config.transformRequest
|
||||
);
|
||||
|
||||
// Merge headers
|
||||
var headers = utils.merge(
|
||||
defaults.headers.common,
|
||||
defaults.headers[config.method] || {},
|
||||
config.headers || {}
|
||||
);
|
||||
|
||||
// Create the request
|
||||
var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
|
||||
request.open(config.method, buildUrl(config.url, config.params), true);
|
||||
|
||||
// Listen for ready state
|
||||
request.onreadystatechange = function () {
|
||||
if (request && request.readyState === 4) {
|
||||
// Prepare the response
|
||||
var headers = parseHeaders(request.getAllResponseHeaders());
|
||||
var response = {
|
||||
data: transformData(
|
||||
request.responseText,
|
||||
headers,
|
||||
config.transformResponse
|
||||
),
|
||||
status: request.status,
|
||||
headers: headers,
|
||||
config: config
|
||||
};
|
||||
|
||||
// Resolve or reject the Promise based on the status
|
||||
(request.status >= 200 && request.status < 300
|
||||
? resolve
|
||||
: reject)(response);
|
||||
|
||||
// Clean up request
|
||||
request = null;
|
||||
}
|
||||
};
|
||||
|
||||
// Add xsrf header
|
||||
var xsrfValue = urlIsSameOrigin(config.url)
|
||||
? cookies.read(config.xsrfCookieName || defaults.xsrfCookieName)
|
||||
: undefined;
|
||||
if (xsrfValue) {
|
||||
headers[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
|
||||
}
|
||||
|
||||
// Add headers to the request
|
||||
utils.forEach(headers, function (val, key) {
|
||||
// Remove Content-Type if data is undefined
|
||||
if (!data && key.toLowerCase() === 'content-type') {
|
||||
delete headers[key];
|
||||
}
|
||||
// Otherwise add header to the request
|
||||
else {
|
||||
request.setRequestHeader(key, val);
|
||||
}
|
||||
});
|
||||
|
||||
// Add withCredentials to request if needed
|
||||
if (config.withCredentials) {
|
||||
request.withCredentials = true;
|
||||
}
|
||||
|
||||
// Add responseType to request if needed
|
||||
if (config.responseType) {
|
||||
try {
|
||||
request.responseType = config.responseType;
|
||||
} catch (e) {
|
||||
if (request.responseType !== 'json') {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (utils.isArrayBuffer(data)) {
|
||||
data = new DataView(data);
|
||||
}
|
||||
|
||||
// Send the request
|
||||
request.send(data);
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 6 */
|
||||
/***/ 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);
|
||||
};
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 7 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
// shim for using process in browser
|
||||
|
||||
var process = module.exports = {};
|
||||
|
||||
process.nextTick = (function () {
|
||||
var canSetImmediate = typeof window !== 'undefined'
|
||||
&& window.setImmediate;
|
||||
var canPost = typeof window !== 'undefined'
|
||||
&& window.postMessage && window.addEventListener
|
||||
;
|
||||
|
||||
if (canSetImmediate) {
|
||||
return function (f) { return window.setImmediate(f) };
|
||||
}
|
||||
|
||||
if (canPost) {
|
||||
var queue = [];
|
||||
window.addEventListener('message', function (ev) {
|
||||
var source = ev.source;
|
||||
if ((source === window || source === null) && ev.data === 'process-tick') {
|
||||
ev.stopPropagation();
|
||||
if (queue.length > 0) {
|
||||
var fn = queue.shift();
|
||||
fn();
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
||||
return function nextTick(fn) {
|
||||
queue.push(fn);
|
||||
window.postMessage('process-tick', '*');
|
||||
};
|
||||
}
|
||||
|
||||
return function nextTick(fn) {
|
||||
setTimeout(fn, 0);
|
||||
};
|
||||
})();
|
||||
|
||||
process.title = 'browser';
|
||||
process.browser = true;
|
||||
process.env = {};
|
||||
process.argv = [];
|
||||
|
||||
function noop() {}
|
||||
|
||||
process.on = noop;
|
||||
process.addListener = noop;
|
||||
process.once = noop;
|
||||
process.off = noop;
|
||||
process.removeListener = noop;
|
||||
process.removeAllListeners = noop;
|
||||
process.emit = noop;
|
||||
|
||||
process.binding = function (name) {
|
||||
throw new Error('process.binding is not supported');
|
||||
}
|
||||
|
||||
// TODO(shtylman)
|
||||
process.cwd = function () { return '/' };
|
||||
process.chdir = function (dir) {
|
||||
throw new Error('process.chdir is not supported');
|
||||
};
|
||||
|
||||
|
||||
/***/ },
|
||||
/* 8 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
function encode(val) {
|
||||
return encodeURIComponent(val).
|
||||
replace(/%40/gi, '@').
|
||||
replace(/%3A/gi, ':').
|
||||
replace(/%24/g, '$').
|
||||
replace(/%2C/gi, ',').
|
||||
replace(/%20/g, '+');
|
||||
}
|
||||
|
||||
module.exports = function buildUrl(url, params) {
|
||||
if (!params) {
|
||||
return url;
|
||||
}
|
||||
|
||||
var parts = [];
|
||||
|
||||
utils.forEach(params, function (val, key) {
|
||||
if (val === null || typeof val === 'undefined') {
|
||||
return;
|
||||
}
|
||||
if (!utils.isArray(val)) {
|
||||
val = [val];
|
||||
}
|
||||
|
||||
utils.forEach(val, function (v) {
|
||||
if (utils.isDate(v)) {
|
||||
v = v.toISOString();
|
||||
}
|
||||
else if (utils.isObject(v)) {
|
||||
v = JSON.stringify(v);
|
||||
}
|
||||
parts.push(encode(key) + '=' + encode(v));
|
||||
});
|
||||
});
|
||||
|
||||
if (parts.length > 0) {
|
||||
url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&');
|
||||
}
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 9 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
module.exports = {
|
||||
write: function write(name, value, expires, path, domain, secure) {
|
||||
var cookie = [];
|
||||
cookie.push(name + '=' + encodeURIComponent(value));
|
||||
|
||||
if (utils.isNumber(expires)) {
|
||||
cookie.push('expires=' + new Date(expires).toGMTString());
|
||||
}
|
||||
|
||||
if (utils.isString(path)) {
|
||||
cookie.push('path=' + path);
|
||||
}
|
||||
|
||||
if (utils.isString(domain)) {
|
||||
cookie.push('domain=' + domain);
|
||||
}
|
||||
|
||||
if (secure === true) {
|
||||
cookie.push('secure');
|
||||
}
|
||||
|
||||
document.cookie = cookie.join('; ');
|
||||
},
|
||||
|
||||
read: function read(name) {
|
||||
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
||||
return (match ? decodeURIComponent(match[3]) : null);
|
||||
},
|
||||
|
||||
remove: function remove(name) {
|
||||
this.write(name, '', Date.now() - 86400000);
|
||||
}
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 10 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
/**
|
||||
* Parse headers into an object
|
||||
*
|
||||
* ```
|
||||
* Date: Wed, 27 Aug 2014 08:58:49 GMT
|
||||
* Content-Type: application/json
|
||||
* Connection: keep-alive
|
||||
* Transfer-Encoding: chunked
|
||||
* ```
|
||||
*
|
||||
* @param {String} headers Headers needing to be parsed
|
||||
* @returns {Object} Headers parsed into an object
|
||||
*/
|
||||
module.exports = function parseHeaders(headers) {
|
||||
var parsed = {}, key, val, i;
|
||||
|
||||
if (!headers) return parsed;
|
||||
|
||||
utils.forEach(headers.split('\n'), function(line) {
|
||||
i = line.indexOf(':');
|
||||
key = utils.trim(line.substr(0, i)).toLowerCase();
|
||||
val = utils.trim(line.substr(i + 1));
|
||||
|
||||
if (key) {
|
||||
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
||||
}
|
||||
});
|
||||
|
||||
return parsed;
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 11 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var utils = __webpack_require__(4);
|
||||
|
||||
/**
|
||||
* Transform the data for a request or a response
|
||||
*
|
||||
* @param {Object|String} data The data to be transformed
|
||||
* @param {Array} headers The headers for the request or response
|
||||
* @param {Array|Function} fns A single function or Array of functions
|
||||
* @returns {*} The resulting transformed data
|
||||
*/
|
||||
module.exports = function transformData(data, headers, fns) {
|
||||
utils.forEach(fns, function (fn) {
|
||||
data = fn(data, headers);
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
/***/ },
|
||||
/* 12 */
|
||||
/***/ function(module, exports, __webpack_require__) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
||||
var utils = __webpack_require__(4);
|
||||
var urlParsingNode = document.createElement('a');
|
||||
var originUrl = urlResolve(window.location.href);
|
||||
|
||||
/**
|
||||
* Parse a URL to discover it's components
|
||||
*
|
||||
* @param {String} url The URL to be parsed
|
||||
* @returns {Object}
|
||||
*/
|
||||
function urlResolve(url) {
|
||||
var href = url;
|
||||
|
||||
if (msie) {
|
||||
// IE needs attribute set twice to normalize properties
|
||||
urlParsingNode.setAttribute('href', href);
|
||||
href = urlParsingNode.href;
|
||||
}
|
||||
|
||||
urlParsingNode.setAttribute('href', href);
|
||||
|
||||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||||
return {
|
||||
href: urlParsingNode.href,
|
||||
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
||||
host: urlParsingNode.host,
|
||||
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
||||
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
||||
hostname: urlParsingNode.hostname,
|
||||
port: urlParsingNode.port,
|
||||
pathname: (urlParsingNode.pathname.charAt(0) === '/')
|
||||
? urlParsingNode.pathname
|
||||
: '/' + urlParsingNode.pathname
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a URL shares the same origin as the current location
|
||||
*
|
||||
* @param {String} requestUrl The URL to test
|
||||
* @returns {boolean} True if URL shares the same origin, otherwise false
|
||||
*/
|
||||
module.exports = function urlIsSameOrigin(requestUrl) {
|
||||
var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;
|
||||
return (parsed.protocol === originUrl.protocol &&
|
||||
parsed.host === originUrl.host);
|
||||
};
|
||||
|
||||
/***/ }
|
||||
/******/ ])
|
||||
//# sourceMappingURL=axios.standalone.map
|
||||
Vendored
+1
File diff suppressed because one or more lines are too long
Vendored
+3
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "axios",
|
||||
"version": "0.3.1",
|
||||
"version": "0.4.0",
|
||||
"description": "Promise based HTTP client for the browser and node.js",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user