You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
839 B

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