You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a scenario where sometimes I want object diff to be considered as the whole object, and sometimes just as a partial object. When applying a partial object, if an existing key isn't provided I want it to just leave it as is. A deep merge option built in could be nice and is I believe can be done very simply.
The way I'm handling this now is after doing a diff, I'm looping through the changes and removing any remove operation:
let changes = diff(this.data, data);
if (merge) {
changes = changes.filter((change) => change.op === 'remove');
}
diffApply(this.data, changes);
For big objects, performance could benefit from this being built in where either diff optionally doesnt include remove operations or when doing diffApply it optionally skips the removals.
Activity
angus-c commentedon Dec 30, 2022
I think this is a good idea but in the spirit of Just maybe should be a separate util. Something like just-diff-new
joezappie commentedon Jan 2, 2023
I think that makes sense to make keep them separate rather than have a configuration option as you suggested.