Releases: fuzetsu/mergerino
0.4.0 no more SUB and consistent behavior
Breaking changes
Removed SUB
export, same behavior can be achieved using a function:
// before
merge({ nested: { deep: true } }, { nested: SUB({ replaced: true }) })
// now
merge({ nested: { deep: true } }, { nested: () => ({ replaced: true }) })
Top level function patches will no longer merge in order to be consistent with lower level function patches. The merge
function is now passed as the second arg to function patches to allow merging without needing to import anything.
Example:
merge(
{
person: { name: 'bob' }
},
{
person: (obj, merge) =>
merge(obj, {
name_backwards: obj.name
.split('')
.reverse()
.join('')
})
}
)
0.3.0 bye bye DEL/SUB, hello (x => x) and undefined
This versions contains breaking changes:
DEL
is no longer exported, specify undefined
as the value to delete properties, use null
if you don't want to delete
// before
merge({ prop: true }, { prop: DEL })
// now
merge({ prop: true }, { prop: undefined })
SUB
is only used to perform replacements and sidestep recursive logic, directly set a function as the value in order to perform a function substitution
// before
merge({ count: 1, nest: { foo: 'bar' } }, { count: SUB(x => x + 1), nest: SUB({}) }
// now
merge({ count: 1, nest: { foo: 'bar' } }, { count: x => x + 1, nest: SUB({}) }
This release also contains 1 bug fix. Previously SUB
operations nested into a path that didn't exist in the source object would be copied in unresolved, leaving mergerino artifacts in state. This has been fixed.