README.md

reductionist

A through stream that acts as a streaming equivalent for Javascript's reduce
method, built off @dominictarr's
map-stream.

Installation

npm install reductionist

Usage

reductionist(iterator, memo, [options])

The iterator callback takes three arguments. memo is the value of the
existing reduction, num is the data being input, and next is a callback
that determines the next value of memo. It's more or less equivalent to
underscore.js.

Passing an error to the callback's first parameter will cause the stream to
emit it and stop accepting input.

By default, reductionist will output the new value of memo each time it
changes. But by passing { every: false } as an option, the stream will only
emit a single data event, once it's been closed: the final value for memo.