update
This commit is contained in:
parent
d9becc67b6
commit
9308795b8b
964 changed files with 104265 additions and 16 deletions
50
node_modules/ramda/es/mergeWithKey.js
generated
vendored
Normal file
50
node_modules/ramda/es/mergeWithKey.js
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
import _curry3 from "./internal/_curry3.js";
|
||||
import _has from "./internal/_has.js";
|
||||
/**
|
||||
* 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 key
|
||||
* and 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.
|
||||
*
|
||||
* @func
|
||||
* @memberOf R
|
||||
* @since v0.19.0
|
||||
* @category Object
|
||||
* @sig ((String, a, a) -> a) -> {a} -> {a} -> {a}
|
||||
* @param {Function} fn
|
||||
* @param {Object} l
|
||||
* @param {Object} r
|
||||
* @return {Object}
|
||||
* @see R.mergeDeepWithKey, R.merge, R.mergeWith
|
||||
* @example
|
||||
*
|
||||
* let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
|
||||
* R.mergeWithKey(concatValues,
|
||||
* { a: true, thing: 'foo', values: [10, 20] },
|
||||
* { b: true, thing: 'bar', values: [15, 35] });
|
||||
* //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
|
||||
* @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 }
|
||||
*/
|
||||
|
||||
var mergeWithKey =
|
||||
/*#__PURE__*/
|
||||
_curry3(function mergeWithKey(fn, l, r) {
|
||||
var result = {};
|
||||
var k;
|
||||
|
||||
for (k in l) {
|
||||
if (_has(k, l)) {
|
||||
result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k];
|
||||
}
|
||||
}
|
||||
|
||||
for (k in r) {
|
||||
if (_has(k, r) && !_has(k, result)) {
|
||||
result[k] = r[k];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
export default mergeWithKey;
|
Loading…
Add table
Add a link
Reference in a new issue