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.
fangdawei
ef5e3ecfd0
|
1 year ago | |
---|---|---|
.. | ||
README.md | 1 year ago | |
index.js | 1 year ago | |
package.json | 1 year ago | |
test.js | 1 year ago |
README.md
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:
- It does not call
.resume()
on streams2+ streams. streams2 streams monkeypatch.pipe
when entering flowing mode; avoidingresume()
avoids that fate. - 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