Custom parser with devalue #4979
-
Hi! I was transfering data with Socket.IO nice and chill until I realised it uses I've also looked at the sample custom parser and it seems much simpler than the default parser. How much is lost when switching to it due to this? Would it makes sense to submit a feature request for this? I think with devalue in general being a very popular serialization option, it would be a nice addition. Many existing libraries/frameworks that need serialization already use it as the default over |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
That's an interesting idea 👍 Would you have time to create a parser based on |
Beta Was this translation helpful? Give feedback.
-
Would it make sense for the devalue repo to just be a fork of the standard parser so it stays up to date and keeps binary support? Or should I take the non-binary parts from the default one and just make a PR with that?
On Tue, 19 Mar 2024 at 16:51, Damien ***@***.***> wrote:
Here we go: https://github.com/socketio/socket.io-devalue-parser
JSON.stringify never throws. devalue throws if it encounters any non-POJO, such as class instances. How should this be handled?
I'd say we should leave it to the user, which can for example implement a toJSON() method on their class.
devalue can't handle binary data, so should the default parser's binary data handling (with deconstruct & reconstruct) be kept as-is?
That's a good question. Maybe we should keep it simple, and not support binary for now?
If the answer to (1) is to leave it up to the user (which most libraries that use devalue seem to do) and to (2) is to leave it as-is, what else other than replacing JSON with devalue should be done?
That's about it I guess.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
Here we go! https://www.npmjs.com/package/@socket.io/devalue-parser