mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
|
// Loaded from https://deno.land/x/ramda@v0.27.2/source/mergeDeepWith.js
|
||
|
|
||
|
|
||
|
import _curry3 from './internal/_curry3.js';
|
||
|
import mergeDeepWithKey from './mergeDeepWithKey.js';
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 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.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] }}
|
||
|
*/
|
||
|
var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) {
|
||
|
return mergeDeepWithKey(function(k, lVal, rVal) {
|
||
|
return fn(lVal, rVal);
|
||
|
}, lObj, rObj);
|
||
|
});
|
||
|
export default mergeDeepWith;
|