Lets imagine you want to test how a lib you created behaves when using its 'stream-mode' and, of course you don't want to read and write from file system. So what should you do? Well you should use this package which is an implementation of Stream.
Because this library implements Node's Stream abstract interface you can use it as you would any other Stream implementation.
$ npm install crispy-stream
Require Crispy Stream
var crispyStream = ;
Creating Read Stream Using a Factory.
If you prefer to have functions creating your streams rather than using the new operator yourself.
// With buffer input.var buff = 'sample text';var readable = crispyStream;// With simple string.var readable = crispyStream;
Creating New Read Stream Using The new Operator.
In case you fancy the Pseudo-classical way.
var Readable = crispyStreamReadable;// With buffer input.var buff = 'sample text';var readable = buff;// With simple string.var readable = 'sample text';
Creating Write Stream Using a Factory.
var writable = crispyStream;
Creating Write Stream Using The new Operator.
var Writable = crispyStreamWritable;var writable = ;
Just as every stream library, you can pipe things from a read stream to a write stream.
Between Crispy Streams.
var input = 'pipe this';var pipable = crispyStream;var writable = crispyStream;pipable;
Between Crispy Stream and Native Stream.
Native Readable to Crispy Writable
var fs = ;var input = '/path/to/input';var pipable = fs;var writable = crispyStream;pipable;
Crispy Readable to Native Writable
var fs = ;var input = 'pipe this';var filename = '/path/to/output';var pipable = crispyStream;var writable = fs;pipable;