Stream multiplexer, with callback ability
npm install suckle
Suckle is a stream multiplexer for node. Give it one readable stream, and it pipes to multiple writable streams.
var suckle = require'suckle'var mux = sucklecreateStream;muxpipeprocessstdout processstdout processstdoutmuxpipeprocessstdout processstdout;muxpipeprocessstdout;processstdinpipemux
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 http = require'http'var Suckle = require'suckle'httpcreateservervar mux = ;muxpiperes;muxonComplete/* Here's your gzipped data */;fscreateReadStream'somefile.jpg'pipezlibcreateGzippipemux;listen8080
Suckle is used internally by Lactate