Stream multiplexer, with callback ability
Suckle is a stream multiplexer for node. You pass it as many writable streams as you want, and it exposes a simple chainable API for treating it as if it were only one. Also, if enabled, you can wedge a callback for when the stream ends. This callback is supplied the accumulated data.
var Suckle = require'suckle'var mux = processstdoutmuxpipeprocessstdoutwrite'asdf\n'processstdinresumeprocessstdinpipemux
The main problem Suckle solves is when you need a callback, to return the piped data. As a case study, say you have a static file server. Ideally, you would like to pipe node's file readStream to gzip, and then to the client. Fine. But what if you also need to cache that gzipped data in an object, for subsequent requests? With Suckle you can!
var fs = require'fs'var zlib = require'zlib'var Suckle = require'suckle'var fileStream = fscreateReadStream'somefile.jpg'var zipper = zlibcreateGzipvar mux = true processstdoutmuxoncomplete/* You can do anything! Anything! /*})zipper.pipe(mux)fileStream.pipe(zipper)