You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

36 lines
1.2 KiB

var _curry3 = require('./internal/_curry3');
var mergeDeepWithKey = require('./mergeDeepWithKey');
/**
* Creates a new object with the own properties of the two provided objects.
* If a key exists in both objects:
* - and both associated values are also objects then the values will be
* recursively merged.
* - otherwise the provided function is applied to associated values using the
* resulting value as the new value associated with the key.
* If a key only exists in one object, the value will be associated with the key
* of the resulting object.
*
* @func
* @memberOf R
* @since v0.24.0
* @category Object
* @sig (a -> a -> a) -> {a} -> {a} -> {a}
* @param {Function} fn
* @param {Object} lObj
* @param {Object} rObj
* @return {Object}
* @see R.mergeWith, R.mergeDeep, R.mergeDeepWithKey
* @example
*
* R.mergeDeepWith(R.concat,
* { a: true, c: { values: [10, 20] }},
* { b: true, c: { values: [15, 35] }});
* //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}
*/
module.exports = _curry3(function mergeDeepWith(fn, lObj, rObj) {
return mergeDeepWithKey(function(k, lVal, rVal) {
return fn(lVal, rVal);
}, lObj, rObj);
});