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

Devalue parser #1

Merged
merged 8 commits into from
Mar 22, 2024
Merged

Devalue parser #1

merged 8 commits into from
Mar 22, 2024

Conversation

rChaoz
Copy link

@rChaoz rChaoz commented Mar 19, 2024

This PR transforms this repo (fork of default parser) from a JSON.stringify/JSON.parse-based parser to one using devalue. Support for binary data is kept as-is - only non-binary data is encoded/decoded with devalue.

As devalue is ESM-only, this parser also needs to be ESM-only, removing the CJS build.

Devalue offers many improvements over the standard (vanilla) JSON encoding, such as:

  • support for undefined, regular expressions, maps and sets (these are completely lost when using JSON),
  • support for Date objects (using JSON they become a string instead)
  • support for BigInt (JSON throws when encountering this)
  • support for custom types (classes) via reducers/revivers

See all here.

@rChaoz
Copy link
Author

rChaoz commented Mar 21, 2024

@darrachequesne don't wanna bother, just wanna know if you have seen this PR? Also, if all is good, what is the process to get this in a package registry?

@darrachequesne darrachequesne merged commit 90a0fd4 into socketio:main Mar 22, 2024
1 of 2 checks passed
@darrachequesne
Copy link
Member

Here we go! https://www.npmjs.com/package/@socket.io/devalue-parser

Thanks a lot for your work on this 👍

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

Successfully merging this pull request may close these issues.

2 participants