mirror of
https://github.com/tenrok/axios.git
synced 2026-05-30 15:24:11 +03:00
Mended merge conflicts
This commit is contained in:
+49
-1
@@ -323,6 +323,52 @@ function stripBOM(content) {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit the prototype methods from one constructor into another
|
||||
* @param {function} constructor
|
||||
* @param {function} superConstructor
|
||||
* @param {object} [props]
|
||||
* @param {object} [descriptors]
|
||||
*/
|
||||
|
||||
function inherits(constructor, superConstructor, props, descriptors) {
|
||||
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
||||
constructor.prototype.constructor = constructor;
|
||||
props && Object.assign(constructor.prototype, props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve object with deep prototype chain to a flat object
|
||||
* @param {Object} sourceObj source object
|
||||
* @param {Object} [destObj]
|
||||
* @param {Function} [filter]
|
||||
* @returns {Object}
|
||||
*/
|
||||
|
||||
function toFlatObject(sourceObj, destObj, filter) {
|
||||
var props;
|
||||
var i;
|
||||
var prop;
|
||||
var merged = {};
|
||||
|
||||
destObj = destObj || {};
|
||||
|
||||
do {
|
||||
props = Object.getOwnPropertyNames(sourceObj);
|
||||
i = props.length;
|
||||
while (i-- > 0) {
|
||||
prop = props[i];
|
||||
if (!merged[prop]) {
|
||||
destObj[prop] = sourceObj[prop];
|
||||
merged[prop] = true;
|
||||
}
|
||||
}
|
||||
sourceObj = Object.getPrototypeOf(sourceObj);
|
||||
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
||||
|
||||
return destObj;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isArray: isArray,
|
||||
isArrayBuffer: isArrayBuffer,
|
||||
@@ -345,5 +391,7 @@ module.exports = {
|
||||
merge: merge,
|
||||
extend: extend,
|
||||
trim: trim,
|
||||
stripBOM: stripBOM
|
||||
stripBOM: stripBOM,
|
||||
inherits: inherits,
|
||||
toFlatObject: toFlatObject
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user