daffMerge
Merges dictionaries with a specific strategy for handling collisions.
Examples
Merging two dictionaries with predefined mergers
const a = {
ary: [1, 2],
obj: {foo: 5, bar: 10}
}
const a = {
ary: [3, 4],
obj: {foo: 6},
fish: 'tacos'
}
const result = daffMerge(
[a, b],
{
ary: daffArrayConcatMerger,
obj: daffDictAssignMerger
}
)
the value of result would be:
{
ary: [1, 2, 3, 4],
obj: {foo: 6, bar: 10},
fish: 'tacos'
}
Merging two dictionaries with predefined mergers
const a = {
ary: [1, 2],
obj: {foo: 5, bar: 10}
}
const a = {
ary: [3, 4],
obj: {foo: 6},
fish: 'tacos'
}
const result = daffMerge(
[a, b],
{
ary: daffArrayConcatMerger,
obj: daffDictAssignMerger
}
)
the value of result would be:
{
ary: [1, 2, 3, 4],
obj: {foo: 6, bar: 10},
fish: 'tacos'
}