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

Can't use constructor key in the object #15

Closed
Rigidoont opened this issue Oct 6, 2022 · 5 comments
Closed

Can't use constructor key in the object #15

Rigidoont opened this issue Oct 6, 2022 · 5 comments

Comments

@Rigidoont
Copy link

Rigidoont commented Oct 6, 2022

Presence of the constructor key in the object seems to break flattening. No errors are produced, the object simply does not get flattened.

@mesqueeb
Copy link
Owner

mesqueeb commented Oct 6, 2022

@Gidoont it might be a reserved keyword for JS to know how an object was made, as a plain object or as a class instance.

I'd advice you to not use the key called constructor but if you must then..... I'm not sure how to fix it yet :P PRs welcome though!

@Rigidoont
Copy link
Author

Unfortunately, it's not up to me whether to use such key or not. I'm receiving a JSON and have to do some work on it.

@Rigidoont
Copy link
Author

Rigidoont commented Oct 6, 2022

@mesqueeb I think here's the issue - https://github.com/mesqueeb/is-what/blob/production/src/index.ts#L46

isPlainObject method is used in https://github.com/mesqueeb/flatten-anything/blob/production/src/index.ts#L11

It does not recognize the object as a plain one if the constructor property is overridden.

@Rigidoont
Copy link
Author

Rigidoont commented Oct 6, 2022

PR - mesqueeb/is-what#24

@mesqueeb
Copy link
Owner

mesqueeb commented Dec 1, 2022

@Gidoont thank you very much! it's released in latest version v3.0.3

@mesqueeb mesqueeb closed this as completed Dec 1, 2022
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