Projekt

Obecné

Profil

Stáhnout (1012 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
# stream-each
2
3
Iterate all the data in a stream
4
5
```
6
npm install stream-each
7
```
8
9
[![build status](http://img.shields.io/travis/mafintosh/stream-each.svg?style=flat)](http://travis-ci.org/mafintosh/stream-each)
10
11
## Usage
12
13
``` js
14
var each = require('stream-each')
15
16
each(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
29
Iterate the data in the stream by calling the iterator function with `(data, next)`
30
where data is a data chunk and next is a callback. Call next when you are ready to
31
consume the next chunk. Optionally you can call next with an error to destroy the stream
32
33
When the stream ends/errors the callback is called if provided
34
35
## License
36
37
MIT
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.