1 | var baseMerge = require('./_baseMerge'),
|
2 | createAssigner = require('./_createAssigner');
|
3 |
|
4 | /**
|
5 | * This method is like `_.merge` except that it accepts `customizer` which
|
6 | * is invoked to produce the merged values of the destination and source
|
7 | * properties. If `customizer` returns `undefined`, merging is handled by the
|
8 | * method instead. The `customizer` is invoked with six arguments:
|
9 | * (objValue, srcValue, key, object, source, stack).
|
10 | *
|
11 | * **Note:** This method mutates `object`.
|
12 | *
|
13 | * @static
|
14 | * @memberOf _
|
15 | * @since 4.0.0
|
16 | * @category Object
|
17 | * @param {Object} object The destination object.
|
18 | * @param {...Object} sources The source objects.
|
19 | * @param {Function} customizer The function to customize assigned values.
|
20 | * @returns {Object} Returns `object`.
|
21 | * @example
|
22 | *
|
23 | * function customizer(objValue, srcValue) {
|
24 | * if (_.isArray(objValue)) {
|
25 | * return objValue.concat(srcValue);
|
26 | * }
|
27 | * }
|
28 | *
|
29 | * var object = { 'a': [1], 'b': [2] };
|
30 | * var other = { 'a': [3], 'b': [4] };
|
31 | *
|
32 | * _.mergeWith(object, other, customizer);
|
33 | * // => { 'a': [1, 3], 'b': [2, 4] }
|
34 | */
|
35 | var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
|
36 | baseMerge(object, source, srcIndex, customizer);
|
37 | });
|
38 |
|
39 | module.exports = mergeWith;
|