mirror of
https://github.com/tenrok/axios.git
synced 2026-05-15 11:59:42 +03:00
Slight refactor/namings/comment on mergeConfig
This commit is contained in:
@@ -4,7 +4,7 @@ var utils = require('../utils');
|
||||
|
||||
/**
|
||||
* Config-specific merge-function which creates a new config-object
|
||||
* based on given defaults and instance config.
|
||||
* by merging two configuration objects together.
|
||||
*
|
||||
* @param {Object} config1
|
||||
* @param {Object} config2
|
||||
@@ -15,13 +15,11 @@ module.exports = function mergeConfig(config1, config2) {
|
||||
config2 = config2 || {};
|
||||
var config = {};
|
||||
|
||||
utils.forEach(['url', 'method', 'params', 'data'], function valueFromInstanceConfig(prop) {
|
||||
if (typeof config2[prop] !== 'undefined') {
|
||||
config[prop] = config2[prop];
|
||||
}
|
||||
utils.forEach(['url', 'method', 'params', 'data'], function valueFromConfig2(prop) {
|
||||
config[prop] = config2[prop];
|
||||
});
|
||||
|
||||
utils.forEach(['headers', 'auth', 'proxy'], function mergeInstanceConfigWithDefaults(prop) {
|
||||
utils.forEach(['headers', 'auth', 'proxy'], function mergeValues(prop) {
|
||||
if (typeof config2[prop] !== 'undefined') {
|
||||
if (typeof config2[prop] === 'object') {
|
||||
config[prop] = utils.deepMerge(config1[prop], config2[prop]);
|
||||
@@ -38,7 +36,7 @@ module.exports = function mergeConfig(config1, config2) {
|
||||
'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
|
||||
'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'maxContentLength',
|
||||
'validateStatus', 'maxRedirects', 'httpAgent', 'httpsAgent', 'cancelToken'
|
||||
], function defaultToInstanceConfig(prop) {
|
||||
], function defaultToConfig2(prop) {
|
||||
config[prop] = typeof config2[prop] === 'undefined' ? config1[prop] : config2[prop];
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user