Cleanup baseMerge.

This commit is contained in:
John-David Dalton
2015-01-14 23:05:24 -08:00
committed by jdalton
parent ae9ac3b439
commit 6dfb2997cb

View File

@@ -2487,11 +2487,9 @@
var isSrcArr = isArray(source) || isTypedArray(source); var isSrcArr = isArray(source) || isTypedArray(source);
(isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) { (isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) {
var isArr = isArray(srcValue) || isTypedArray(srcValue), var value = object[key];
isObj = isPlainObject(srcValue),
value = object[key];
if (!(isArr || isObj)) { if (!isObjectLike(srcValue)) {
var result = customizer ? customizer(value, srcValue, key, object, source) : undefined, var result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
isCommon = typeof result == 'undefined'; isCommon = typeof result == 'undefined';
@@ -2519,9 +2517,12 @@
isCommon = typeof result == 'undefined'; isCommon = typeof result == 'undefined';
if (isCommon) { if (isCommon) {
result = isArr result = srcValue;
? (isArray(value) ? value : []) if (isArray(srcValue) || isTypedArray(srcValue)) {
: (isPlainObject(value) ? value : {}); result = isArray(value) ? value : [];
} else if (isPlainObject(srcValue)) {
result = isPlainObject(value) ? value : {};
}
} }
// Add the source value to the stack of traversed objects and associate // Add the source value to the stack of traversed objects and associate
// it with its merged value. // it with its merged value.