/** Make Promise or AsyncIterable abortable with the given signal. */ export declare function abortable(p: Promise, signal: AbortSignal): Promise; export declare function abortable(p: AsyncIterable, signal: AbortSignal): AsyncGenerator; /** Make AsyncIterable abortable with the given signal. */ export declare function abortableAsyncIterable(p: AsyncIterable, signal: AbortSignal): AsyncGenerator; /** Make Promise abortable with the given signal. */ export declare function abortablePromise(p: Promise, signal: AbortSignal): Promise; /** * Create a promise which will be rejected with DeadlineError when a given delay is exceeded. */ export declare function deadline(p: Promise, delay: number): Promise; export declare class DeadlineError extends Error { constructor(); } /** * Creates a debounced function that delays the given `func` * by a given `wait` time in milliseconds. If the method is called * again before the timeout expires, the previous call will be * aborted. * * ``` * import { debounce } from "./debounce.ts"; * * const log = debounce( * (event: Deno.FsEvent) => * console.log("[%s] %s", event.kind, event.paths[0]), * 200, * ); * * for await (const event of Deno.watchFs("./")) { * log(event); * } * ``` * * @param fn The function to debounce. * @param wait The time in milliseconds to delay the function. */ export declare function debounce>(fn: (this: DebouncedFunction, ...args: T) => void, wait: number): DebouncedFunction; /** * A debounced function that will be delayed by a given `wait` * time in milliseconds. If the method is called again before * the timeout expires, the previous call will be aborted. */ export declare interface DebouncedFunction> { (...args: T): void; /** Clears the debounce timeout and omits calling the debounced function. */ clear(): void; /** Clears the debounce timeout and calls the debounced function immediately. */ flush(): void; /** Returns a boolean wether a debounce call is pending or not. */ readonly pending: boolean; } export declare interface Deferred extends Promise { readonly state: "pending" | "fulfilled" | "rejected"; resolve(value?: T | PromiseLike): void; reject(reason?: any): void; } /** Creates a Promise with the `reject` and `resolve` functions * placed as methods on the promise object itself. It allows you to do: * * ```ts * import { deferred } from "./deferred.ts"; * * const p = deferred(); * // ... * p.resolve(42); * ``` */ export declare function deferred(): Deferred; export declare function delay(ms: number, options?: DelayOptions_2): Promise; declare interface DelayOptions_2 { signal?: AbortSignal; } export { DelayOptions_2 as DelayOptions } /** The MuxAsyncIterator class multiplexes multiple async iterators into a * single stream. It currently makes an assumption: * - The final result (the value returned and not yielded from the iterator) * does not matter; if there is any, it is discarded. */ export declare class MuxAsyncIterator implements AsyncIterable { private iteratorCount; private yields; private throws; private signal; add(iterable: AsyncIterable): void; private callIteratorNext; iterate(): AsyncIterableIterator; [Symbol.asyncIterator](): AsyncIterator; } /** * pooledMap transforms values from an (async) iterable into another async * iterable. The transforms are done concurrently, with a max concurrency * defined by the poolLimit. * * If an error is thrown from `iterableFn`, no new transformations will begin. * All currently executing transformations are allowed to finish and still * yielded on success. After that, the rejections among them are gathered and * thrown by the iterator in an `AggregateError`. * * @param poolLimit The maximum count of items being processed concurrently. * @param array The input array for mapping. * @param iteratorFn The function to call for every item of the array. */ export declare function pooledMap(poolLimit: number, array: Iterable | AsyncIterable, iteratorFn: (data: T) => Promise): AsyncIterableIterator; /** * Branches the given async iterable into the n branches. * * Example: * * ```ts * import { tee } from "./tee.ts"; * * const gen = async function* gen() { * yield 1; * yield 2; * yield 3; * } * * const [branch1, branch2] = tee(gen()); * * (async () => { * for await (const n of branch1) { * console.log(n); // => 1, 2, 3 * } * })(); * * (async () => { * for await (const n of branch2) { * console.log(n); // => 1, 2, 3 * } * })(); * ``` */ export declare function tee(iterable: AsyncIterable, n?: N): Tuple, N>; declare type Tuple = N extends N ? number extends N ? T[] : TupleOf : never; declare type TupleOf = R["length"] extends N ? R : TupleOf; export { }