-
-
Notifications
You must be signed in to change notification settings - Fork 549
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
Jsonify correctness #410
Jsonify correctness #410
Conversation
- it now handles transformation of Number, String and Boolean to primitive counterparts - it correctly turns function and symbol to null as array members - it omits entries in objects where values are function, symbol or undefined; and where keys are symbols - it fails on BigInt with never
You need to fix the lint errors. |
What's the difficulty with supporting TypedArrays? |
Both |
Sorry for the lint errors point, I thought they were there before but I was mistaken. I fixed them all. I'll investigate the typed arrays and update the readme about limitations. |
@sindresorhus I think it should be ready for review. I fixed newly introduced lint errors as well. |
Thanks for contributing 🙏 |
This is my first attempt at fixing Jsonify problems I mentioned in #407.
I started with tests first, then proceeded to fix those tests. Tests are based on MDN docs and my own tests.
I had to delete a faulty test case, where an object had a function value. The spec tells that those entries are omitted from the output.
I checked the validity of the types with the provided
test
script. It also output a lot of lint warnings that were there before I picked it up, so I left them alone. I can fix those errors if you want me to, but it will end up destroying the git blame.I'm not sure if I documented everything I did as best as I could, since this was a first attempt. I can fix anything where you thing it needs more explanation.
I also commented out the Infinity and NaN checks. Infinity is detectable with this library, but it seemed like a minor edge case. NaN is not detectable as far as I can understand, see #406.
Also missing is
TypedArray
s. I'm not sure how to approach them, any guidance is welcome, or we can get this merged and leave it as future work.I can also add a warning about NaNs in the readme, or leave it as future work as well.
Sorry for a lot of text, I just wanted to cover everything.
Fixes #407