@unction/mergewith
v13.14.0
Published
Takes a function that determines how to merge two conflicting values in a merge
Downloads
126
Readme
@unction/mergeWith
MapperFunctionType<A, MapperFunctionType<A, A>> => Array | Set | Record<string | number | symbol, B> | Map<B, A> | string => Array | Set | Record<string | number | symbol, B> | Map<B, A> | string => Array | Set | Record<string | number | symbol, B> | Map<B, A> | string
Merges two enumerables and uses a provided function to handle conflicts. The function is given the the left value and the right value.
const left = {
alpha: "0",
beta: "1",
zeta: "3"
}
const right = {
alpha: "0",
beta: "2",
zeta: "3"
}
mergeWith((l) => (r) => l+r)(left)(right)
Which returns:
{
alpha: "0",
beta: "12",
zeta: "3"
}