stream-end

0.1.0 • Public • Published

stream-end NPM version Build Status

Just a callback when the stream ends. Called if the upstream is flowing with 'data' events or using Streams2 style reads.

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.

Package Sidebar

Install

npm i stream-end

Weekly Downloads

14

Version

0.1.0

License

none

Last publish

Collaborators

  • hurrymaplelad