Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detailedDiff doesn't return deleted elements #76

Closed
joniba opened this issue Feb 22, 2022 · 1 comment
Closed

detailedDiff doesn't return deleted elements #76

joniba opened this issue Feb 22, 2022 · 1 comment

Comments

@joniba
Copy link

joniba commented Feb 22, 2022

Deleted doesn't seem to work in the detailedDiff method. Examples:

let b1 = { a: 1 }
let b2 = {  }
console.log(JSON.stringify(differ.detailedDiff(b1, b2))); //output: {"added":{},"deleted":{},"updated":{}}
let b1 = { a: 1 }
let b2 = { b: 3 }
console.log(JSON.stringify(differ.detailedDiff(b1, b2))); //output: {"added":{"b":3},"deleted":{},"updated":{}}
@mattphillips
Copy link
Owner

Hey @joniba looks like this is happening because you are using JSON.stringify which doesn't support undefined which is used by this library to represent deleted values.

I think this is a duplicate of #10. This comment shows how you can use JSON.stringify with the deleted elements of a diff: #10 (comment)

Going to close this but feel free to re-open / comment should I have misunderstood anything 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants