Skip to content

Commit

Permalink
Removed array check
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Stone committed Nov 12, 2020
1 parent 3b66e4c commit 2ae7430
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit 2ae7430

Please sign in to comment.