MCPcopy Create free account
hub / github.com/RubyLouvre/anu / baseMergeDeep

Function baseMergeDeep

test/babel.js:51805–51856  ·  view source on GitHub ↗

* A specialized version of `baseMerge` for arrays and objects which performs * deep merges and tracks traversed objects enabling objects with circular * references to be merged. * * @private * @param {Object} object The destination object. * @param {Object} source The source object. *

(object, source, key, srcIndex, mergeFunc, customizer, stack)

Source from the content-addressed store, hash-verified

51803 * counterparts.
51804 */
51805 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
51806 var objValue = object[key],
51807 srcValue = source[key],
51808 stacked = stack.get(srcValue);
51809
51810 if (stacked) {
51811 assignMergeValue(object, key, stacked);
51812 return;
51813 }
51814 var newValue = customizer ? customizer(objValue, srcValue, key + '', object, source, stack) : undefined;
51815
51816 var isCommon = newValue === undefined;
51817
51818 if (isCommon) {
51819 var isArr = isArray(srcValue),
51820 isBuff = !isArr && isBuffer(srcValue),
51821 isTyped = !isArr && !isBuff && isTypedArray(srcValue);
51822
51823 newValue = srcValue;
51824 if (isArr || isBuff || isTyped) {
51825 if (isArray(objValue)) {
51826 newValue = objValue;
51827 } else if (isArrayLikeObject(objValue)) {
51828 newValue = copyArray(objValue);
51829 } else if (isBuff) {
51830 isCommon = false;
51831 newValue = cloneBuffer(srcValue, true);
51832 } else if (isTyped) {
51833 isCommon = false;
51834 newValue = cloneTypedArray(srcValue, true);
51835 } else {
51836 newValue = [];
51837 }
51838 } else if (isPlainObject(srcValue) || isArguments(srcValue)) {
51839 newValue = objValue;
51840 if (isArguments(objValue)) {
51841 newValue = toPlainObject(objValue);
51842 } else if (!isObject(objValue) || srcIndex && isFunction(objValue)) {
51843 newValue = initCloneObject(srcValue);
51844 }
51845 } else {
51846 isCommon = false;
51847 }
51848 }
51849 if (isCommon) {
51850 // Recursively merge objects and arrays (susceptible to call stack limits).
51851 stack.set(srcValue, newValue);
51852 mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
51853 stack['delete'](srcValue);
51854 }
51855 assignMergeValue(object, key, newValue);
51856 }
51857
51858 module.exports = baseMergeDeep;
51859

Callers 1

baseMergeFunction · 0.85

Calls 13

assignMergeValueFunction · 0.85
isArrayFunction · 0.85
isBufferFunction · 0.85
isArrayLikeObjectFunction · 0.85
copyArrayFunction · 0.85
cloneBufferFunction · 0.85
cloneTypedArrayFunction · 0.85
isArgumentsFunction · 0.85
toPlainObjectFunction · 0.85
initCloneObjectFunction · 0.85
isPlainObjectFunction · 0.70
isObjectFunction · 0.70

Tested by

no test coverage detected