mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Bump to v4.0.0.
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
var merge = require('../object/merge');
|
||||
var baseClone = require('./baseClone'),
|
||||
baseMerge = require('./baseMerge'),
|
||||
isObject = require('../isObject');
|
||||
|
||||
/**
|
||||
* Used by `_.defaultsDeep` to customize its `_.merge` use.
|
||||
*
|
||||
* @private
|
||||
* @param {*} objectValue The destination object property value.
|
||||
* @param {*} sourceValue The source object property value.
|
||||
* @returns {*} Returns the value to assign to the destination object.
|
||||
* @param {*} objValue The destination value.
|
||||
* @param {*} srcValue The source value.
|
||||
* @param {string} key The key of the property to merge.
|
||||
* @param {Object} object The parent object of `objValue`.
|
||||
* @param {Object} source The parent object of `srcValue`.
|
||||
* @param {Object} [stack] Tracks traversed source values and their merged counterparts.
|
||||
* @returns {*} Returns the value to assign.
|
||||
*/
|
||||
function mergeDefaults(objectValue, sourceValue) {
|
||||
return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults);
|
||||
function mergeDefaults(objValue, srcValue, key, object, source, stack) {
|
||||
if (isObject(objValue) && isObject(srcValue)) {
|
||||
stack.set(srcValue, objValue);
|
||||
baseMerge(objValue, srcValue, mergeDefaults, stack);
|
||||
}
|
||||
return objValue === undefined ? baseClone(srcValue) : objValue;
|
||||
}
|
||||
|
||||
module.exports = mergeDefaults;
|
||||
|
||||
Reference in New Issue
Block a user