stream-end
v0.1.0
Published
I just want a callback when the stream ends
Downloads
106
Maintainers
Readme
stream-end
Just a callback when the stream ends. Called if the upstream is flowing with 'data'
events or using Streams2 style read
s.
Usage
I needed this for use with gulp, but it works with any stream.
gulp.src('specs/*.spec.coffee', {read: false})
.pipe(mocha())
.pipe(end(function() {
return devServer.close();
}));
Why!?
Can't we just use stream.on('end', cb)
?
I wish. Unfortunately, streams are messy. There are at least 3 api conventions in node.
With some combinations of stream versions, the readable stream returned by pipe isn't flowing unless you manually resume()
it. If you just register an 'end'
listener, it may never be called. If the retured stream is flowing, your 'end
' listner get's called just fine. It's a brittle habit.