mergeWith.js•1.06 kB
var _curry3 = require('./internal/_curry3');
var mergeWithKey = require('./mergeWithKey');
/**
* Creates a new object with the own properties of the two provided objects. If
* a key exists in both objects, the provided function is applied to the values
* associated with the key in each object, with the result being used as the
* value associated with the key in the returned object. The key will be
* excluded from the returned object if the resulting value is `undefined`.
*
* @func
* @memberOf R
* @since v0.19.0
* @category Object
* @sig (a -> a -> a) -> {a} -> {a} -> {a}
* @param {Function} fn
* @param {Object} l
* @param {Object} r
* @return {Object}
* @see R.merge, R.mergeWithKey
* @example
*
* R.mergeWith(R.concat,
* { a: true, values: [10, 20] },
* { b: true, values: [15, 35] });
* //=> { a: true, b: true, values: [10, 20, 15, 35] }
*/
module.exports = _curry3(function mergeWith(fn, l, r) {
return mergeWithKey(function(_, _l, _r) {
return fn(_l, _r);
}, l, r);
});