import type { Fn2, Maybe } from "@thi.ng/api"; import type { IClosable, IWriteable } from "./api.js"; import { Channel } from "./channel.js"; export declare const broadcast: (src: Channel, dest: Channel[], close?: boolean) => Promise; export declare const concat: (dest: IWriteable & IClosable, chans: Iterable>, close?: boolean) => Promise; /** * Consumes & collects all queued and future values written to channel `chan` * until closed or the max. number of values has been collected (whatever comes * first). Returns a promise of the result array. * * @param chan * @param res * @param num */ export declare const consume: (chan: Channel, res?: T[], num?: number) => Promise; /** * Consumes all queued and future values written to channel `chan` until closed * or the max. number of values has been reached (whatever comes first). Calls * `fn` with each value read (presumably for side effects). Returns a void * promise which resolves when the consumer is done. * * @param chan * @param fn * @param num */ export declare const consumeWith: (chan: Channel, fn: Fn2, void>, num?: number) => Promise; /** * Similar to {@link consume}, but only processes any current in-flight writes * and returns a promise with an array of their values. * * @param chan */ export declare const drain: (chan: Channel) => Promise[]>; /** * Takes an async iterable and returns a new CSP {@link Channel}, which receives * all values from `src` (via {@link pipe}). If `close` is true (default), the * channel will be automatically closed once the iterable is exhausted. Returns * the new channel. * * @param src * @param close */ export declare const fromAsyncIterable: (src: AsyncIterable, close?: boolean) => Channel; export declare const merge: (src: Channel[], dest?: Channel, close?: boolean) => Channel; /** * Receives values from `src` and writes them to `dest` for as long as it's * accepting new writes (i.e. isn't closed from elsewhere). If `close` is true * (default), the `dest` channel will be automatically closed once the `src` is * exhausted. Returns a void-promise which resolves once done. * * @param dest * @param src * @param close */ export declare const into: & IClosable>(dest: DEST, src: Iterable | AsyncIterable, close?: boolean) => Promise; /** * Similar to {@link into} (and also calls that function asynchronously), but * `pipe()` itself is synchronous and returns `dest` channel immediatedly. * * @remarks * Also note different argument order! * * @param src * @param dest * @param close */ export declare const pipe: & IClosable>(src: AsyncIterable, dest: DEST, close?: boolean) => DEST; /** * Takes one or more input channels and attempts to read from all of them at * once (via {@link Channel.race}, a blocking op). Returns a promise which * resolves once one of the inputs becomes available or was closed, selects that * channel to read from it and returns tuple of `[value, channel]`. If the * selected channel already is closed, returns `[undefined, channel]`. * * @remarks * Since v3.3.0 inputs are automatically shuffled to avoid selection bias. * * @param input - first input * @param rest - other inputs */ export declare const select: (input: Channel, ...rest: Channel[]) => Promise<[Maybe, Channel]>; /** * Returns a new {@link Channel} which will automatically close after `delay` * milliseconds. * * @remarks * Intended as utility for enforcing a timeout for {@link select}-style * operations. * * @param delay */ export declare const timeout: (delay: number) => Channel; //# sourceMappingURL=ops.d.ts.map