makeChannel

function makeChannel<T = any>(bufferType?: CreatableBufferType, capacity?: number, id?: string): Channel<T>

import { makeChannel } from 'csp-coffee/channel' 

Default buffer type is Fixed and default capacity is 1.

The first argument is the buffer type. The second argument is capacity of our channel i.e how many values it can hold before buffer logic comes into play. The last argument is id and by default this will be a uuid v4 string, but you can specify a custom id for debugging purposes.

Channel

id: string

This is either an auto generated uuid string or id passed to makeChannel function

isClosed: boolean

The name is self-explanatory. This flag indicates whether the channel is closed or not. Closed channel does not contain any values and cannot be supplied with new ones.

isBuffered: boolean

Indicates whether the channel will block the operations which want to insert a new value into it. Is a proxy for underlying buffer's isBlocked property.

capacity: number

Maximum number of items the channel can hold before internal buffer behavior comes into play.

is: (ch: Channel) => boolean;

Is method used to compare two channels for equality based on their ids.

Symbol.asyncIterator()

Every channel in this library is async iterable

Last updated