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

Cannot use 'in' operator to search for ... in null #7

Closed
zarmin opened this issue Nov 7, 2021 · 6 comments
Closed

Cannot use 'in' operator to search for ... in null #7

zarmin opened this issue Nov 7, 2021 · 6 comments

Comments

@zarmin
Copy link

zarmin commented Nov 7, 2021

const diff = require('microdiff').default
const a1 = {"a": { "b": 1 }}
const a2 = {"a": null}
console.log(diff(a1, a2))
/Users/.../node_modules/microdiff/dist/index.cjs:8
		if (!(key in newObj)) {
		          ^

TypeError: Cannot use 'in' operator to search for 'b' in null
@AsyncBanana
Copy link
Owner

Thanks for reporting this! I will work on a fix, it should not take long.

AsyncBanana added a commit that referenced this issue Nov 7, 2021
@AsyncBanana
Copy link
Owner

Ok, this should be fixed now. Let me know if you continue to have problems with this in version v1.1.1+.

@AbdallahAbis
Copy link

@AsyncBanana I'm having same issue in "microdiff": "^1.3.2"

@AsyncBanana
Copy link
Owner

Could you send me the relevant code?

@AsyncBanana AsyncBanana reopened this Jan 9, 2024
@AndreyMay
Copy link

AndreyMay commented Jul 7, 2024

Getting the same issue (comparing arrays of objects with arrays inside). It happens when the root object is undefined or null (might want to check that).

@AsyncBanana
Copy link
Owner

Microdiff expects basic objects or arrays. I would handle any other values before passing them to the diff function.

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

4 participants