node.js - Piping Readable -> Writable streams -- emit vs data? -


i have code uses max ogden's websocket-stream library (https://github.com/maxogden/websocket-stream), pretty nifty.

when this:

websocketstream.on('data', function(data){     console.log(data); }); 

i arraybuffer in client (what want, binary websocket stream).

when try implement writable stream (using prototypes or whatever), i'm getting arraybufferview in _write instead of bare arraybuffer :-(. i'm using objectmode:true.

the simplest example is:

var s = new writable({objectmode:true}); s._write = function(chunk, enc, next){     console.log(chunk); // arraybufferview     console.log(enc); // `buffer`     next(); } websocketstream.pipe(s); 

who's newing buffer view, , how can stop them?

the workaround take chunk in write , grab .buffer. i'm doing best understand 'implementors' side of newer streams interface, , love things correctly.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -