Permalink
Browse files

Make sure read streams end even if no selectors match

When the trumpet stream ends, call `.end()` on any read streams created
that have not yet been ended. This happens when the selector did not
match any elements.
  • Loading branch information...
1 parent 897ac97 commit 4e04c8f1ce4a479e535a4b60188782b8ce924422 @parshap parshap committed with Nov 13, 2013
Showing with 9 additions and 0 deletions.
  1. +9 −0 index.js
View
@@ -56,6 +56,15 @@ module.exports = function (opts) {
return tr.select(sel).createStream(opts);
};
+ // End any read streams of unmatched selectors
+ tr.on("end", function() {
+ selectors.forEach(function(r) {
+ r._readStreams.forEach(function(s) {
+ if (s.readable) s.end();
+ });
+ });
+ });
+
return tr;
function createResult (sel, opts) {

0 comments on commit 4e04c8f

Please sign in to comment.