Add 'Channel.all'.

This commit is contained in:
David 2021-02-02 14:58:39 -06:00
parent fb598b0270
commit fd503a978c
3 changed files with 33 additions and 1 deletions

View file

@ -4,6 +4,7 @@
- [close() -> (async)](#close-async)
- [readOnly() -> Channel](#readonly-channel)
- [writeOnly() -> Channel](#writeonly-channel)
- [Channel.all(channels) -> Channel](#channelallchannels-channel)
- [Channel.select(promises) -> (async) channel](#channelselectpromises-async-channel)
- [Examples](#examples)
- [value()](#value)
@ -44,7 +45,7 @@ The following properties don't have equivalents in `Array`.
Close the channel so that no more values can be pushed to it. Return a promise
that resolves when any remaining pushes in flight complete.
Attempting to push to a closed channel will throw an exception and shifting from
Attempting to push to a closed channel will throw an exception. Shifting from
a closed channel will immediately return `undefined`.
## readOnly() -> Channel
@ -55,6 +56,11 @@ Return a version of the channel that provides only read methods.
Return a version of the channel that provides only write methods.
## Channel.all(channels) -> Channel
Take an array of channels and wait for the next value in each one before pushing
an array of the values to a newly created channel. Similar to `Promise.all`.
## Channel.select(promises) -> (async) channel
Wait for the first channel method promise to succeed and then cancel the rest.