Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/parshap/node-stream-reduce
Reduce stream data to a single value
https://github.com/parshap/node-stream-reduce
Last synced: 2 months ago
JSON representation
Reduce stream data to a single value
- Host: GitHub
- URL: https://github.com/parshap/node-stream-reduce
- Owner: parshap
- Created: 2013-08-09T22:22:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-03-07T18:53:41.000Z (almost 11 years ago)
- Last Synced: 2024-11-08T09:50:45.517Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 137 KB
- Stars: 20
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-nodejs - node-stream-reduce - Reduce stream data to a single value. (Repository / Streams)
- awesome-nodejs-streams - parshap/node-stream-reduce - Reduce stream data to a single value (Modules)
README
# stream-reduce
Like [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/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.# Example
```js
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);
});
```# Installation
```
npm install stream-reduce
```