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
mux-demux streams can't be fed buffers #2
Comments
This was a problem with |
I've installed |
I'm not sure converting the buffer to a string is the right approach: it presumes the other end is happy with the default utf8 encoding and knows when/if the source has been encoded. My patch to mux-demux is somewhat grotty, but ensures that Buffer objects always come out the other end as Buffer objects. |
oh, of course, my fix didn't work in mux-demux because the buffer is put inside an array, so it's stringified as normal. I'm not gonna merge this patch, because as you say it's somewhat grotty, I've patched mux-demux to support custom serialization formats. using msgpack-stream should work for your purposes. also, what I'd like to have a stream interface for the redis protocol. here is a redis parser. |
oh, you want mux-demux@2.1.0 |
this issue is related nodejs/node-v0.x-archive#3848 |
I have that usecase where some of the streams are binary and others aren't. What should I do? I converted binary to string streams and that works. |
you could use msg-pack instead of json. here is an example https://github.com/dominictarr/mux-demux/blob/master/test/msg-pack.js |
Shouldn't mux-demux support buffers out of the box? I'd really like to be able to just pipe binary data around if I want. A binary protocol that's more efficient than JSON would be nice too. EDIT: Nevermind, I didn't see the msgpack version. It works beautifully! A note in the README about buffers would be nice. |
@tlrobinson good point - fixed in 3.7.9 |
Per gist 3253513, piping streams involving Buffers rather than strings to mux-demux results in the other end of the mux stream sending
data
events with buffer-shaped JavaScript objects rather than anything you could pipe further, e.g. into a socket or file stream.The text was updated successfully, but these errors were encountered: