In the following example sink should wait for all piped streams to unpipe() before calling _flush.
As it currently stands the following code outputs:
If you remove the // applyFix(); comment you get:
varthrough=require('through2');vartap1=through.obj();vartap2=through.obj();varsink=through.obj(transform,flush);varpipes=0;// applyFix();tap1.pipe(sink);tap2.pipe(sink);tap1.write('a');tap1.end();setTimeout(function(){tap2.write('b');tap2.end();},100);functionapplyFix(){sink.on('pipe',function(){pipes++;});sink.end=function(){if(!--pipes){sink._flush();}};}functionflush(){console.log('done');}functiontransform(item,e,next){console.log(item);this.push(item);next();}ref: #89
In the following example
sinkshould wait for all piped streams tounpipe()before calling_flush.As it currently stands the following code outputs:
$ node test1.js a doneIf you remove the
// applyFix();comment you get:$ node test1.js a b doneref: #89