merge-deep-with-key

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
5
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
1 KB
Creates a new object with the own properties of the two provided objects.
1 contributor
Install merge-deep-with-key as a package?
Copied
npm i @bit/justin-capalbo.ramda.merge-deep-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
mergeDeepWithKey (
fn:Function,
lObj:Object,
rObj:Object
) : Object

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 the key and 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.
Example
let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
     R.mergeDeepWithKey(concatValues,
                        { a: true, c: { thing: 'foo', values: [10, 20] }},
                        { b: true, c: { thing: 'bar', values: [15, 35] }});
     //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }}
Arguments
fn: Function
lObj: Object
rObj: Object
Returns
Object

Help and resources