47df56fbd804af5738cb0433f976ca1b4804f677c1f4a8b4a6c29cf1fbf1e24487561a28aa8b17f72a39430d610e0b87665955e74dd66691d46618966a40db 1012 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # stream-each
  2. Iterate all the data in a stream
  3. ```
  4. npm install stream-each
  5. ```
  6. [![build status](http://img.shields.io/travis/mafintosh/stream-each.svg?style=flat)](http://travis-ci.org/mafintosh/stream-each)
  7. ## Usage
  8. ``` js
  9. var each = require('stream-each')
  10. each(stream, function (data, next) {
  11. console.log('data from stream', data)
  12. // when ready to consume next chunk
  13. next()
  14. }, function (err) {
  15. console.log('no more data')
  16. })
  17. ```
  18. ## API
  19. #### `each(stream, iterator, cb)`
  20. Iterate the data in the stream by calling the iterator function with `(data, next)`
  21. where data is a data chunk and next is a callback. Call next when you are ready to
  22. consume the next chunk. Optionally you can call next with an error to destroy the stream
  23. When the stream ends/errors the callback is called if provided
  24. ## License
  25. MIT
  26. ## Related
  27. `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.