Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
.npmignore | D | 12-May-2024 | 13 | 2 | 1 | |
.travis.yml | D | 12-May-2024 | 62 | 6 | 5 | |
LICENSE | D | 12-May-2024 | 1.1 KiB | 22 | 17 | |
README.md | D | 12-May-2024 | 1,012 | 42 | 27 | |
collaborators.md | D | 12-May-2024 | 352 | 8 | 5 | |
index.js | D | 12-May-2024 | 1,019 | 59 | 47 | |
package.json | D | 12-May-2024 | 1.6 KiB | 60 | 59 | |
test.js | D | 12-May-2024 | 2 KiB | 123 | 103 |
README.md
1# stream-each 2 3Iterate all the data in a stream 4 5``` 6npm install stream-each 7``` 8 9[](http://travis-ci.org/mafintosh/stream-each) 10 11## Usage 12 13``` js 14var each = require('stream-each') 15 16each(stream, function (data, next) { 17 console.log('data from stream', data) 18 // when ready to consume next chunk 19 next() 20}, function (err) { 21 console.log('no more data') 22}) 23``` 24 25## API 26 27#### `each(stream, iterator, cb)` 28 29Iterate the data in the stream by calling the iterator function with `(data, next)` 30where data is a data chunk and next is a callback. Call next when you are ready to 31consume the next chunk. Optionally you can call next with an error to destroy the stream 32 33When the stream ends/errors the callback is called if provided 34 35## License 36 37MIT 38 39## Related 40 41`stream-each` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one. 42