1 var copyObjectWith = require('./_copyObjectWith'),
2 createAssigner = require('./_createAssigner'),
3 keys = require('./keys');
6 * This method is like `_.assign` except that it accepts `customizer` which
7 * is invoked to produce the assigned values. If `customizer` returns `undefined`
8 * assignment is handled by the method instead. The `customizer` is invoked
9 * with five arguments: (objValue, srcValue, key, object, source).
11 * **Note:** This method mutates `object`.
16 * @param {Object} object The destination object.
17 * @param {...Object} sources The source objects.
18 * @param {Function} [customizer] The function to customize assigned values.
19 * @returns {Object} Returns `object`.
22 * function customizer(objValue, srcValue) {
23 * return _.isUndefined(objValue) ? srcValue : objValue;
26 * var defaults = _.partialRight(_.assignWith, customizer);
28 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
29 * // => { 'a': 1, 'b': 2 }
31 var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
32 copyObjectWith(source, keys(source), object, customizer);
35 module.exports = assignWith;