rschmukler / stream-series

Merge streams and emit in order
30 stars 2 forks source link

stream series callback #2

Open tamtakoe opened 9 years ago

tamtakoe commented 9 years ago

I want to do some action after streams end. But I need to return result stream which will be end after my actions will be completed (f.e. I create file in first stream and use this file for second stream). It can realise if stream-series will get callback as parameter

var orderedStream = series(streamA, streamB,
    function() {
        //It will be done after streamA and streamB ended
        streamC = new Stream();
        streamC.end('c');

        return streamC;
    }    
);

streamB.end('b');
streamA.end('a');

var writer = es.writeArray(function(err, array) {
  // Array will be ['a', 'b', 'c'];
});

orderedStream.pipe(writer);