Class: Channel

Channel()

new Channel()

As asynchronous channel, possibly buffered. Takes either a capacity argument (a number) or no arguments. The channel will have the given capacity if specified; otherwise returns an unbuffered channel.
Source:

Methods

close()

Closes this channel. This channel will not accept any more puts, and takes will only consume puts already enqueued.
Source:

error(err)

Put an error on the channel. Returns a promise that will yield a boolean value when the put has completed. The promise will always yield true unless the channel is closed.
Parameters:
Name Type Description
err The error to put on the channel.
Source:
Returns:
The promise.

isClosed() → {boolean}

Tell if this channel is closed.
Source:
Returns:
True if closed.
Type
boolean

put(val)

Put a value on the channel. Returns a promise that will yield a boolean value when the put has completed. The promise will always yield true unless the channel is closed.
Parameters:
Name Type Description
val The value to put on the channel.
Source:
Returns:
The promise.

take() → {Promise.<never>|Promise.<unknown>}

Take a value from the channel. Returns a promise that will yield the value read once a corresponding put call is made. Returns a promise that yields null if the channel is closed.
Source:
Returns:
Type
Promise.<never> | Promise.<unknown>