Permalink
Browse files

hack to buffer end events from event emitters

  • Loading branch information...
1 parent 5abfa09 commit 62bb4fafcc9dd6f4038767d9b0ffc17326c348e7 @substack committed Nov 10, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −2 index.js
  2. +0 −1 test/single.js
View
@@ -42,7 +42,8 @@ module.exports = function (obj) {
s.write(buf);
});
- part.on('end', function () {
+ part.once('end', function () {
+ s._caughtEnd = true;
s.end();
});
return s;
@@ -67,7 +68,12 @@ module.exports = function (obj) {
});
part.pipe(s);
- part.on('end', pop);
+ part.once('end', pop);
+ if (part._caughtEnd) {
+ process.nextTick(function () {
+ part.emit('end');
+ });
+ }
part.resume();
}
});
View
@@ -1,6 +1,5 @@
var gutter = require('../');
var fs = require('fs');
-var es = require('event-stream');
var test = require('tap').test;
var EventEmitter = require('events').EventEmitter;
var BufferedStream = require('morestreams').BufferedStream;

0 comments on commit 62bb4fa

Please sign in to comment.