diff --git a/index.js b/index.js index 962a6d9..2c43868 100644 --- a/index.js +++ b/index.js @@ -56,20 +56,19 @@ function propertyIsUnsafe(target, key) { } // Retrieves either a new object or the appropriate target object to mutate. -function getDestinationObject(target, source, options) { +function getDestinationObject(target, options) { const targetDefined = typeof target !== 'undefined' - const isArray = Array.isArray(target) || Array.isArray(source) const doMerge = options && (options.mergeWithTarget || options.clone === false) if (targetDefined && doMerge) { return Array.isArray(target) ? firstArrayEntry(target) : target } - return isArray ? [] : {}; + return {}; } function mergeObject(target, source, options) { - var destination = getDestinationObject(target, source, options) + var destination = getDestinationObject(target, options) if (options.isMergeableObject(target)) { getKeys(target).forEach(function(key) { destination[key] = cloneUnlessOtherwiseSpecified(target[key], options) @@ -117,7 +116,7 @@ deepmerge.all = function deepmergeAll(array, options) { return array.reduce(function(prev, next) { return deepmerge(prev, next, options) - }, getDestinationObject(array, undefined, options)) + }, getDestinationObject(array, options)) } module.exports = deepmerge