node package manager



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 = suckle.createStream();
mux.pipe(process.stdout, process.stdout, process.stdout)
mux.pipe(process.stdout, process.stdout);

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')
http.createserver(function(req, res) {
    var mux = new Suckle;
    mux.onComplete(function(data, length) {
      /* Here's your gzipped data */

Suckle is used internally by Lactate