eb7915b508d45ab442663a7eac74a79ffc1937af
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / assignWith.js
1 var copyObjectWith = require('./_copyObjectWith'),
2     createAssigner = require('./_createAssigner'),
3     keys = require('./keys');
4
5 /**
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).
10  *
11  * **Note:** This method mutates `object`.
12  *
13  * @static
14  * @memberOf _
15  * @category 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`.
20  * @example
21  *
22  * function customizer(objValue, srcValue) {
23  *   return _.isUndefined(objValue) ? srcValue : objValue;
24  * }
25  *
26  * var defaults = _.partialRight(_.assignWith, customizer);
27  *
28  * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
29  * // => { 'a': 1, 'b': 2 }
30  */
31 var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
32   copyObjectWith(source, keys(source), object, customizer);
33 });
34
35 module.exports = assignWith;