-
Notifications
You must be signed in to change notification settings - Fork 64
Once .end() is called, it can never be called again even if autoDestroy is false. #18
Comments
Here's a fairly simple example. This doesn't work like I'd expect: var es = require('event-stream');
var myThrough = es.through(null, function() {
this.queue('(DONE)\n');
});
myThrough.autoDestroy = false;
myThrough.pipe(process.stdout);
var noise1 = es.through();
noise1.pipe(myThrough);
noise1.write('This is test #1.\n');
noise1.end('Done #1!\n');
var noise2 = es.through();
noise2.pipe(myThrough);
noise2.write('This is test #2.\n');
noise2.end('Done #2!\n');
console.log('All done.'); Because even though
By overwriting var es = require('event-stream');
var myThrough = es.through();
myThrough.end = function(data) {
if (arguments.length) { this.queue(data); }
this.queue('(DONE)\n');
this.writable = this.readable = true; // unsure if this is necessary
return this;
};
myThrough.pipe(process.stdout);
var noise1 = es.through();
noise1.pipe(myThrough);
noise1.write('This is test #1.\n');
noise1.end('Done #1!\n');
var noise2 = es.through();
noise2.pipe(myThrough);
noise2.write('This is test #2.\n');
noise2.end('Done #2!\n');
console.log('All done.'); Which outputs this:
|
In [email protected] supported multisink pipes like this, but it was removed in 0.6, as it's a pretty rare edgecase. If you want to have a stream that can do that, you should make it a new module. |
In my use-case, the |
Well, there is probably the odd case where you might want to do that. |
Per these 2 lines once
.end()
is called, it's impossible to ever effectively utilize.end()
again, because the local variableended
is always set.Should
ended
only be set here ifautoDestroy === true
?I mean, what's the point of keeping a stream around if you can no longer fully utilize it?
The text was updated successfully, but these errors were encountered: