mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Bump to v4.0.0.
This commit is contained in:
43
mergeWith.js
Normal file
43
mergeWith.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import baseMerge from './internal/baseMerge';
|
||||
import createAssigner from './internal/createAssigner';
|
||||
|
||||
/**
|
||||
* This method is like `_.merge` except that it accepts `customizer` which
|
||||
* is invoked to produce the merged values of the destination and source
|
||||
* properties. If `customizer` returns `undefined` merging is handled by the
|
||||
* method instead. The `customizer` is invoked with seven arguments:
|
||||
* (objValue, srcValue, key, object, source, stack).
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Object
|
||||
* @param {Object} object The destination object.
|
||||
* @param {...Object} sources The source objects.
|
||||
* @param {Function} customizer The function to customize assigned values.
|
||||
* @returns {Object} Returns `object`.
|
||||
* @example
|
||||
*
|
||||
* function customizer(objValue, srcValue) {
|
||||
* if (_.isArray(objValue)) {
|
||||
* return objValue.concat(srcValue);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* var object = {
|
||||
* 'fruits': ['apple'],
|
||||
* 'vegetables': ['beet']
|
||||
* };
|
||||
*
|
||||
* var other = {
|
||||
* 'fruits': ['banana'],
|
||||
* 'vegetables': ['carrot']
|
||||
* };
|
||||
*
|
||||
* _.mergeWith(object, other, customizer);
|
||||
* // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
|
||||
*/
|
||||
var mergeWith = createAssigner(function(object, source, customizer) {
|
||||
baseMerge(object, source, customizer);
|
||||
});
|
||||
|
||||
export default mergeWith;
|
||||
Reference in New Issue
Block a user