Create a new Channel.
The maximum number of items to buffer. Defaults to 0; i.e. all push()/throw() calls will wait for a matching then() call.
A list of buffered items in the channel
A list of receivers waiting for an item to be sent
List of senders waiting for a receiver / buffer space
The number of items currently buffered.
True if this channel is closed and no longer accepts new values.
Returns true if this channel is closed and contains no buffered items or waiting senders.
A Promise that will resolve when this Channel is closed.
Enables async iteration over the channel. The iterator will stop and throw on the first error encountered.
Send the given Item. Returns a Promise that resolves when sent.
Clear the channel of all buffered items.
Also throws a ChannelClearedError
to awaiting senders.
Does not close the Channel.
Close this channel.
Pass true to clear all buffered items / senders when closing the Channel. Defaults to false.
Wait for the next value (or error) on this channel.
A Promise that resolves/rejects when the next value (or error) on this channel is emitted.
Throws the given error to all waiting receivers. Useful if you want to interrupt all waiting routines immediately.
Send a new value over the channel.
The value to send, or a Promise resolving to a value.
A Promise that resolves when the value has been successfully pushed.
Wait for the next value (or error) on this channel and process it.
Shorthand for chan.get().then(...)
.
Throw a new error in the channel. Note that errors are also buffered and subject to buffer capacity.
A Promise that resolves when the error has been successfully thrown.
Generated using TypeDoc
A BaseChannel serves as a way to send asynchronous values across concurrent lines of execution.