UNPKG

837 BJavaScriptView Raw
1import apply from './_apply.js';
2import baseRest from './_baseRest.js';
3import customDefaultsMerge from './_customDefaultsMerge.js';
4import mergeWith from './mergeWith.js';
5
6/**
7 * This method is like `_.defaults` except that it recursively assigns
8 * default properties.
9 *
10 * **Note:** This method mutates `object`.
11 *
12 * @static
13 * @memberOf _
14 * @since 3.10.0
15 * @category Object
16 * @param {Object} object The destination object.
17 * @param {...Object} [sources] The source objects.
18 * @returns {Object} Returns `object`.
19 * @see _.defaults
20 * @example
21 *
22 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
23 * // => { 'a': { 'b': 2, 'c': 3 } }
24 */
25var defaultsDeep = baseRest(function(args) {
26 args.push(undefined, customDefaultsMerge);
27 return apply(mergeWith, undefined, args);
28});
29
30export default defaultsDeep;