Create a new IteratorChannel.
the iterable source to take elements from.
An optional maximum number of items to take from the source before closing this Channel.
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.
Close this channel.
Pass true to clear all buffered items / senders when closing the Channel. Defaults to false.
Applies the given filter function to the values from this Channel and returns a new Channel with only the filtered values.
A function that takes a value from this Channel and returns a boolean of whether to include the value in the resulting Channel. May return a Promise or a plain value. Defaults to passing all values.
A function that takes an error from this Channel and returns a boolean of whether to include the error in the resulting Channel. May return a Promise or a plain value. Defaults to passing all values.
The number of "coroutines" to spawn to perform this operation. Must be positive and finite. Defaults to 1.
The buffer size of the output channel. Defaults to 0.
Consumes each value from this Channel, applying the given function on each. Errors on the Channel or in the function will cause the returned Promise to reject.
A function to invoke with each value from this Channel.
A function to invoke with each error from this Channel.
The number of "coroutines" to spawn to perform this operation. Must be positive and finite. Defaults to 1.
A Promise that resolves when all values have been consumed, or rejects when an error is received from the Channel.
Throws the given error to all waiting receivers. Useful if you want to interrupt all waiting routines immediately.
Applies the given 1-to-1 mapping function to this Channel and returns a new Channel with the mapped values.
A function that maps values from this Channel. To map to an error, either throw or return a rejecting Promise. May return a Promise or a plain value. If omitted, values will be propagated as-is.
A function that maps errors from this Channel to values. To map to an error, either throw or return a rejecting Promise. May return a Promise or a plain value. If omitted, errors will be propagated as-is.
The number of "coroutines" to spawn to perform this operation. Must be positive and finite. Defaults to 1.
The buffer size of the output channel. Defaults to 0.
Returns a new Channel that reads up to n
items from this Channel
The number of items to read from this Channel
Wait for the next value (or error) on this channel and process it.
Shorthand for chan.get().then(...)
.
Consumes the values in this Channel and inserts them into an Array. Returns a Promise that resolves to that Array if no errors were emitted.
Applies a transformation function, applying the transformation to this Channel until it is empty and
The transformation function. This function may read from the given input channel and write to the given output channel as desired. Because this function should at minimum read from the input channel, and possibly write to the output channel, it should return a Promise in order for concurrency limits to be obeyed.
The number of "coroutines" to spawn to perform this operation. Must be positive and finite. Defaults to 1.
The buffer size of the output channel. Defaults to 0.
Creates a new Channel from a given source.
Creates a new Channel for the given values. A new Channel will be created with these values.
A list of values to be processed. These may be Promises, in which case they will be flattened.
Generated using TypeDoc
An IteratorChannel automatically emits values from an (async-)iterable source. It uses a pull-based mechanism for fetching the values -- i.e. iteration is not started until the first get() call is made.