You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.0KB

123456789101112131415161718192021222324252627282930313233
  1. # stream-exhaust
  2. Ensure that the provided stream is flowing data, even if the stream hasn't been
  3. piped to another stream.
  4. ```javascript
  5. var exhaustively = require('stream-exhaust');
  6. exhaustively(fs.createReadStream(__filename))
  7. .on('close', () => { console.log('all done, despite being streams{1+N}!') });
  8. ```
  9. ## Prior Art
  10. This is based on [stream-consume](https://github.com/aroneous/stream-consume)
  11. by [aroneous](https://github.com/aroneous). It is a separate package because it has
  12. different semantics:
  13. 1. It does not call `.resume()` on streams2+ streams. streams2 streams monkeypatch `.pipe`
  14. when entering flowing mode; avoiding `resume()` avoids that fate.
  15. 2. It does not examine `._readableState`; instead it checks for the presence of `._read`.
  16. ## API
  17. ### exhaust(Stream s) -> Stream s
  18. Takes a stream, `s`, and returns it. Ensures that the stream is flowing, either by calling
  19. `.resume()` if the stream is a streams1 stream, or by piping it to a "black hole" stream that
  20. continually asks for more data.
  21. ## License
  22. MIT