import type { Fn2, Maybe } from "@thi.ng/api";
import type { IClosable, IWriteable } from "./api.js";
import { Channel } from "./channel.js";
export declare const broadcast: <T>(src: Channel<T>, dest: Channel<T>[], close?: boolean) => Promise<void>;
export declare const concat: <T>(dest: IWriteable<T> & IClosable, chans: Iterable<Channel<T>>, close?: boolean) => Promise<void>;
/**
 * 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: <T>(chan: Channel<T>, res?: T[], num?: number) => Promise<T[]>;
/**
 * 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: <T>(chan: Channel<T>, fn: Fn2<T, Channel<T>, void>, num?: number) => Promise<void>;
/**
 * 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: <T>(chan: Channel<T>) => Promise<Awaited<T>[]>;
/**
 * 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: <T>(src: AsyncIterable<T>, close?: boolean) => Channel<T>;
export declare const merge: <T>(src: Channel<T>[], dest?: Channel<T>, close?: boolean) => Channel<T>;
/**
 * 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: <T, DEST extends IWriteable<T> & IClosable>(dest: DEST, src: Iterable<T> | AsyncIterable<T>, close?: boolean) => Promise<void>;
/**
 * 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: <T, DEST extends IWriteable<T> & IClosable>(src: AsyncIterable<T>, 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]`.
 *
 * @param input - first input
 * @param rest - other inputs
 */
export declare const select: <T>(input: Channel<T>, ...rest: Channel<T>[]) => Promise<[Maybe<T>, Channel<T>]>;
/**
 * 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<any>;
//# sourceMappingURL=ops.d.ts.map