recursive-diff icon indicating copy to clipboard operation
recursive-diff copied to clipboard

[Question] Diff ignoring "nullish" values

Open JSEvgeny opened this issue 1 year ago • 1 comments

Hey there I hope you are doing great,

I was wondering if there is a away to ignore fields that have nullish values when diffing?

The use-case could be having, let's say, some value as undefined in the source object, but empty string or empty array for the same field in target (transformer may have converted undefined values to empty/nullish) and I would like not to consider these as a change for specific property, but ignore it from changes object.

Thank you in advance and have a great day 🙌

JSEvgeny avatar Feb 06 '24 09:02 JSEvgeny

Hey, thanks for reaching out. This feature doesn't exist at the moment. Probably a custom comparator function we can take to customize the target diff. A workaround would be to traverse the diff object and deleting the values having nullish update. You can utilize keepOldValueInDiff parameter so that old value is also there in the diff object.

cosmicanant avatar Feb 17 '24 04:02 cosmicanant