UNPKG

1.29 kBJavaScriptView Raw
1var _curry3 =
2/*#__PURE__*/
3require("./internal/_curry3");
4
5var mergeDeepWithKey =
6/*#__PURE__*/
7require("./mergeDeepWithKey");
8/**
9 * Creates a new object with the own properties of the two provided objects.
10 * If a key exists in both objects:
11 * - and both associated values are also objects then the values will be
12 * recursively merged.
13 * - otherwise the provided function is applied to associated values using the
14 * resulting value as the new value associated with the key.
15 * If a key only exists in one object, the value will be associated with the key
16 * of the resulting object.
17 *
18 * @func
19 * @memberOf R
20 * @since v0.24.0
21 * @category Object
22 * @sig ((a, a) -> a) -> {a} -> {a} -> {a}
23 * @param {Function} fn
24 * @param {Object} lObj
25 * @param {Object} rObj
26 * @return {Object}
27 * @see R.mergeWith, R.mergeDeepWithKey
28 * @example
29 *
30 * R.mergeDeepWith(R.concat,
31 * { a: true, c: { values: [10, 20] }},
32 * { b: true, c: { values: [15, 35] }});
33 * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }}
34 */
35
36
37var mergeDeepWith =
38/*#__PURE__*/
39_curry3(function mergeDeepWith(fn, lObj, rObj) {
40 return mergeDeepWithKey(function (k, lVal, rVal) {
41 return fn(lVal, rVal);
42 }, lObj, rObj);
43});
44
45module.exports = mergeDeepWith;
\No newline at end of file