Closed rogierschouten closed 9 years ago
Basically, this would solve the second concern of https://github.com/poelstra/ts-stream/issues/2#issuecomment-110876701
Fixed in 0.4.1, by using the second argument to end()
.
This is now already supported by map()
and filter()
.
If you want to support it in your own transforms, use it like:
(readable, writable) => {
readable.forEach(
(v) => ...,
(err) => writable.end(err, readable.ended())
);
}
Btw, it may be a good idea that I rename ended()
to e.g. result()
in the near future, as it may be a bit confusing now that the promise returned by ended()
resolves a lot later than that of end()
.
I don't have a strong opinion, 'result' sounds good too
Renamed to result()
in 0.5.1.
It is often handy to know at the reading side whether the end() has completed entirely, i.e. the end() promise has been resolved all the way back to the writer. To this end, it may be possible to connect the ended() method in such a way that it resolves to the ended() of the source.