/** * lodash 3.10.0 (Custom Build) * Build: `lodash modern modularize exports="npm" -o ./` * Copyright 2012-2015 The Dojo Foundation * Based on Underscore.js 1.8.3 * Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors * Available under MIT license */ var merge = require('lodash.merge'), restParam = require('lodash.restparam'); /** * Creates a `_.defaults` or `_.defaultsDeep` function. * * @private * @param {Function} assigner The function to assign values. * @param {Function} customizer The function to customize assigned values. * @returns {Function} Returns the new defaults function. */ function createDefaults(assigner, customizer) { return restParam(function(args) { var object = args[0]; if (object == null) { return object; } args.push(customizer); return assigner.apply(undefined, args); }); } /** * 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. */ function mergeDefaults(objectValue, sourceValue) { return objectValue === undefined ? sourceValue : merge(objectValue, sourceValue, mergeDefaults); } /** * This method is like `_.defaults` except that it recursively assigns * default properties. * * **Note:** This method mutates `object`. * * @static * @memberOf _ * @category Object * @param {Object} object The destination object. * @param {...Object} [sources] The source objects. * @returns {Object} Returns `object`. * @example * * _.defaultsDeep({ 'user': { 'name': 'barney' } }, { 'user': { 'name': 'fred', 'age': 36 } }); * // => { 'user': { 'name': 'barney', 'age': 36 } } * */ var defaultsDeep = createDefaults(merge, mergeDefaults); module.exports = defaultsDeep;