caolan/highland — pull request #161 by LewisJEllis (2014-11-23 23:48:59+00:00)
Title: Implements done, modifies each to return a stream

A proposal for `.done()` as discussed in #55.

This modifies `.each` so that, instead of returning undefined, it returns a stream that ends after the return of the last call of the iterator.

Done is then derived from `toArray`, with the special `.ended` check for cases like:

_([1,2,3]).each(function (x) {
// do something
}).done(function () {
// do something else
});

where `each` will have already ended due to its synchronous source.