grncdr / merge-stream

Merge multiple streams into one interleaved stream
MIT License
214 stars 16 forks source link

Add isEmpty method #15

Closed nervo closed 9 years ago

nervo commented 9 years ago

When a stream is "empty" (aka. no sources were added), it could not be returned to a gulp task, and i suppose this situation could come across somewhere else.

So, now, we can imagine a something like that:

stream = require('merge-stream')();
// Something like a loop to add some streams to the merge stream
// stream.add(streamA);
// stream.add(streamB);
return stream.isEmpty() ? null : stream;
nervo commented 9 years ago

Knock knock, anyone there ?

grncdr commented 9 years ago

LGTM, please add a test so that the Travis build passes and I will merge & release.

nervo commented 9 years ago

Sorry for taking so long time, man :)

I'm a little bit lost in yout tests, "Statements" are ok (100%), but still got an "Error: Timed out: isEmpty". Any clue ?

grncdr commented 9 years ago

The test is timing out because the stream is never consumed. Adding stream.on('data', function (n) { assert.equal(1, n) }) should fix it.

nervo commented 9 years ago

Well, n equals 0 and not 1, and test pass. 'seems to be ok for you ?

grncdr commented 9 years ago

Looks great, thanks for seeing this through!

grncdr commented 9 years ago

Published in 0.1.8