JSPM

stream-exhaust

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1714381
  • Score
    100M100P100Q201437F
  • License MIT

Ensure that a stream is flowing data without mutating it

Package Exports

  • stream-exhaust

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stream-exhaust) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

stream-exhaust

Ensure that the provided stream is flowing data, even if the stream hasn't been piped to another stream.

var exhaustively = require('stream-exhaust');

exhaustively(fs.createReadStream(__filename))
  .on('close', () => { console.log('all done, despite being streams{1+N}!') });

Prior Art

This is based on stream-consume by aroneous. It is a separate package because it has different semantics:

  1. It does not call .resume() on streams2+ streams. streams2 streams monkeypatch .pipe when entering flowing mode; avoiding resume() avoids that fate.
  2. It does not examine ._readableState; instead it checks for the presence of ._read.

API

exhaust(Stream s) -> Stream s

Takes a stream, s, and returns it. Ensures that the stream is flowing, either by calling .resume() if the stream is a streams1 stream, or by piping it to a "black hole" stream that continually asks for more data.

License

MIT