stream-wrapper
Drop-in replacement for the core stream module
that allows you to wrap read
/write
/transform
functions into streams.
npm install stream-wrapper
All streams create are stream2 streams
Readable Stream
var stream = ;var rs = stream;
If you don't have a read
function just omit it
var rs = stream;rs;
The Readable prototype is exposed through stream.Readable
.
Writable Stream
var stream = ;var ws = stream;
The Writable prototype is exposed through stream.Writable
.
Duplex Stream
var stream = ;var ds = stream;
The Duplex prototype is exposed through stream.Duplex
Transform Stream
var stream = ;var ts = stream;
If you want to add a flush function pass it as the second parameter
var ts = stream;
The Transform prototype is exposed through stream.Transform
Stream options
If you want to pass stream options (like objectMode
) pass them as the first
parameter to readable
, writable
, duplex
or transform
var rs = stream;
Stream defaults
You can change the default options for the stream by calling defaults
// all streams created have objectMode enabledstream = stream;
Stream.destroy
All streams have a .destroy
method implemented per default that when called
emits close
and sets stream.destroyed = true
.
var rs = stream;rs;rs;
License
MIT