Reduce stream data to a single value

npm install stream-reduce
8 downloads in the last day
190 downloads in the last week
471 downloads in the last month


Like Array.prototype.reduce but for streams. Given a sync reduce function and an initial value it will return a through stream that emits a single data event with the reduced value once the input stream ends.


var reduce = require("stream-reduce");

process.stdin.pipe(reduce(function(acc, data) {
    return acc + data.length;
}, 0)).on("data", function(length) {
    console.log("stdin size:", length);


npm install stream-reduce
npm loves you