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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -