Collection
Overview
iterate<Channels extends Channel[]>(callback: (data: FlattenChannels) => any, ...chs: Channels): Generator
import { fromArray, iterate } from 'csp-coffee/operators'
import { go } from 'csp-coffee/go';
const ch = fromArray([1, 2, 3]);
const ch2 = fromArray([4, 5, 6]);
// channel produced by fromArray function
// is automatically closed once all values are taken
function* testGenerator () {
yield iterate((val) => {
console.log(val);
}, ch, ch2);
}
go(testGenerator)
// 1
// 2
// 3
// 4
// 5
// 6drain<C extends Channel>(ch: C): Promise<FlattenChannel[]>
map<Channels extends Channel[], M extends unknown = any>(mapFn: (data: FlattenChannels) => M, channels: Channels, { bufferType, capacity }?: ChannelConfiguration): ChannelTransformationResponse
filter<Channels extends Channel[]>(filterFn: (data: FlattenChannels) => boolean, channels: Channels, { bufferType, capacity }?: ChannelConfiguration): ChannelTransformationResponse<FlattenChannels>
reduce<Channels extends Channel[], A = unknown>(reducer: (acc: A, data: FlattenChannels) => A, acc: A, channels: Channels, { bufferType, capacity }?: ChannelConfiguration): ChannelTransformationResponse
Last updated