merge-with-key

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
7
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
998 B
Creates a new object with the own properties of the two provided objects.
1 contributor
Install merge-with-key as a package?
Copied
npm i @bit/justin-capalbo.ramda.merge-with-key
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
mergeWithKey (
fn:Function,
l:Object,
r:Object
) : Object

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.

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] }
Arguments
fn: Function
l: Object
r: Object
Returns
Object

Help and resources