node package manager



An augmentation module for Stream, adds support for map, filter and reduce, The passed functions are applied to the data and their return values writen into the stream again. Internally uses a secondary stream that will be piped to the target one. Please note the following:

  • Reduce must wait for the Stream to end, obviously.
  • To do this, a mapBuffered method is provided.
  • I'm aware that the Stream object will likely change in next node's versions, I'll delete this package as soon as we get support for this functionality.

Some examples

An angry echo server:

var net = require('net');
var Stream = require('..');

        return 'NO, '+buff.toString('utf8').toUpperCase();

> echo "are you angry?" | nc localhost 47641

An http server that performs byte sums:

var http = require('http');
var Stream = require('..');

http.createServer(function(req, res){
    req.reduce(function(acc, buff){
        acc = parseInt(acc) + buff.length; 
        return acc.toString();
    }, 0).pipe(res);

> curl -XPOST -d @index.js http://localhost:21934 
> 2213