Skip to content

merge
210 bytes

Combine two lists overriding items in the first

Usage

Given two arrays of items and an identity function, returns the first list with all items from the second list where there was a match.

import * as _ from 'radashi'
const gods = [
{
name: 'Zeus',
power: 92,
},
{
name: 'Ra',
power: 97,
},
]
const newGods = [
{
name: 'Zeus',
power: 100,
},
]
const mergedGods = _.merge(gods, newGods, f => f.name) // => [{name: "Zeus" power: 100}, {name: "Ra", power: 97}]