Utils

close<T = unknown>(ch: Channel): void

import { close } from 'csp-coffee/channel/utils/close' 

Will correctly close a channel.

hasValues(ch: Channel): boolean

import { hasValues } from 'csp-coffee/channel/utils/hasValues' 

Will return true if channel has any values

isChannelClosedError(e: unknown): boolean

import { isChannelClosedError } from 'csp-coffee/channel/utils/isChannelClosedError' 

Indicates whether a value is an error thrown by closed channel.

waitForIncomingPut<C extends Channel>(ch: C): Generator<undefined, void, unknown>

import { waitForIncomingPut } from 'csp-coffee/channel/utils/waitForIncomingPut' 

Will return a generator which is done once any put request is received by the channel

waitForIncomingPutAsync: (ch: Channel) => Promise

import { waitForIncomingPutAsync } from 'csp-coffee/channel/utils/waitForIncomingPutAsync' 

A promise version of waitForIncomingPut

waitForIncomingTake<C extends Channel>(ch: C): Generator<undefined, void, unknown>

import { waitForIncomingTake } from 'csp-coffee/channel/utils/waitForIncomingTake' 

Will return a generator which is done once any take request is received by the channel

waitForPutQueueToRelease<C extends Channel>(ch: C): Generator<undefined, void, unknown>

import { waitForPutQueueToRelease } from 'csp-coffee/channel/utils/waitForPutQueueToRelease' 

Will return a generator which is done once the channel is ready to accept new incoming put requests or in other words will not block the next incoming put request.

waitForPutQueueToReleaseAsync: (ch: Channel) => Promise<void>

import { waitForPutQueueToReleaseAsync } from 'csp-coffee/channel/utils/waitForPutQueueToRelease' 

A promise version of waitForPutQueueToRelease

waitForTakeQueueToRelease<C extends Channel>(ch: C): Generator<undefined, void, unknown>

import { waitForTakeQueueToRelease } from 'csp-coffee/channel/utils/waitForTakeQueueToRelease' 

Will return a generator which is done once the channel is ready to accept new take requests or in other words will not block the next incoming take request.

waitUntilBufferEmpty<C extends Channel>(ch: C): Generator<undefined, void, unknown>

import { waitUntilBufferEmpty } from 'csp-coffee/channel/utils/waitUntilBufferEmpty' 

Will return a generator which is done once the channel has no put requests to process e.g put queue is empty.

waitUntilBufferIsEmptyAsync: (ch: Channel) => Promise<void>

import { waitUntilBufferIsEmptyAsync } from 'csp-coffee/channel/utils/waitUntilBufferIsEmptyAsync' 

Is a promise version of waitUntilBufferEmpty.

Last updated