Skip to content

Commit

Permalink
dont emit closing events
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Aug 17, 2015
1 parent dd29191 commit 11ec2a7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ module.exports = function (stream, opts) {
var eventNamesToEmit = toMap(opts.events || []);
var catchAll = Object.keys(eventNamesToEmit).length === 0;

var eventNamesToExclude = toMap(opts.excludeEvents || []);
var endEvents = [
'abort',
'close',
'destroy',
'end',
'finish',
'prefinish'
];
var eventNamesToExclude = toMap(opts.excludeEvents || endEvents);

watchPipe(stream);

Expand Down
17 changes: 17 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ describe('stream-forward', function () {
assert.strictEqual(sourceStream, returnedStream);
});

it('does not try to finish a piped stream', function () {
var streamThatErrors = through();

streamForward(streamThatErrors)
.pipe(through(function(chunk, enc, next) {
// let this back up so that if the source stream emits 'finish', and
// streamforward tries to re-emit that event on this stream, it will
// throw.
}));

streamThatErrors.write('blah');

assert.doesNotThrow(function() {
streamThatErrors.emit('prefinish');
});
});

it('forwards all events by default', function (done) {
var eventsEmitted = 0;

Expand Down

0 comments on commit 11ec2a7

Please sign in to comment.