mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Bump to v3.7.0.
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
import arrayEach from './arrayEach';
|
||||
import baseForOwn from './baseForOwn';
|
||||
import baseMergeDeep from './baseMergeDeep';
|
||||
import getSymbols from './getSymbols';
|
||||
import isArray from '../lang/isArray';
|
||||
import isLength from './isLength';
|
||||
import isObject from '../lang/isObject';
|
||||
import isObjectLike from './isObjectLike';
|
||||
import isTypedArray from '../lang/isTypedArray';
|
||||
import keys from '../object/keys';
|
||||
|
||||
/** Used for native method references. */
|
||||
var arrayProto = Array.prototype;
|
||||
|
||||
/** Native method references. */
|
||||
var push = arrayProto.push;
|
||||
|
||||
/**
|
||||
* The base implementation of `_.merge` without support for argument juggling,
|
||||
@@ -17,29 +24,39 @@ import isTypedArray from '../lang/isTypedArray';
|
||||
* @param {Function} [customizer] The function to customize merging properties.
|
||||
* @param {Array} [stackA=[]] Tracks traversed source objects.
|
||||
* @param {Array} [stackB=[]] Associates values with source counterparts.
|
||||
* @returns {Object} Returns the destination object.
|
||||
* @returns {Object} Returns `object`.
|
||||
*/
|
||||
function baseMerge(object, source, customizer, stackA, stackB) {
|
||||
if (!isObject(object)) {
|
||||
return object;
|
||||
}
|
||||
var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source));
|
||||
(isSrcArr ? arrayEach : baseForOwn)(source, function(srcValue, key, source) {
|
||||
if (!isSrcArr) {
|
||||
var props = keys(source);
|
||||
push.apply(props, getSymbols(source));
|
||||
}
|
||||
arrayEach(props || source, function(srcValue, key) {
|
||||
if (props) {
|
||||
key = srcValue;
|
||||
srcValue = source[key];
|
||||
}
|
||||
if (isObjectLike(srcValue)) {
|
||||
stackA || (stackA = []);
|
||||
stackB || (stackB = []);
|
||||
return baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
|
||||
baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
|
||||
}
|
||||
var value = object[key],
|
||||
result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
||||
isCommon = typeof result == 'undefined';
|
||||
else {
|
||||
var value = object[key],
|
||||
result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
|
||||
isCommon = result === undefined;
|
||||
|
||||
if (isCommon) {
|
||||
result = srcValue;
|
||||
}
|
||||
if ((isSrcArr || typeof result != 'undefined') &&
|
||||
(isCommon || (result === result ? (result !== value) : (value === value)))) {
|
||||
object[key] = result;
|
||||
if (isCommon) {
|
||||
result = srcValue;
|
||||
}
|
||||
if ((isSrcArr || result !== undefined) &&
|
||||
(isCommon || (result === result ? (result !== value) : (value === value)))) {
|
||||
object[key] = result;
|
||||
}
|
||||
}
|
||||
});
|
||||
return object;
|
||||
|
||||
Reference in New Issue
Block a user