@rainydio/through-reduce
v1.0.1
Published
Stream reducer
Downloads
4
Readme
Similar to Array.prototype.reduce
"use strict";
const assert = require("assert");
const through = require("through2");
const reduce = require("@rainydio/through-reduce");
const stream = through.obj();
stream
.pipe(reduce((a, b) => a + b, 0))
.pipe(through.obj((sum, enc, done) => {
assert(sum === 6);
done();
}));
stream.write(1);
stream.write(2);
stream.write(3);
stream.end();