import { MaybeAsync } from '../types'; /** * Returns a function that executes with limited concurrency. */ export declare function pLimitFn(fn: (...args: ArgsType) => ReturnType | Promise, limit?: number): ((...args: ArgsType) => Promise) & { clear(): void; }; /** * Only allows one outstanding call. * Returns same promise while task is executing. */ export declare function pOne(fn: (...args: ArgsType) => ReturnType | Promise): ((...args: ArgsType) => Promise); /** * Only allows calling `fn` once. * Returns same promise while task is executing. */ export declare function pOnce(fn: (...args: ArgsType) => ReturnType | Promise): ((...args: ArgsType) => Promise) & { reset(): void; isStarted(): boolean; }; export declare class TimeoutError extends Error { timeout: number; constructor(msg?: string, timeout?: number); } /** * Takes a promise and a timeout and an optional message for timeout errors. * Returns a promise that rejects when timeout expires, or when promise settles, whichever comes first. * * Invoke with positional arguments for timeout & message: * await pTimeout(promise, timeout, message) * * or using an options object for timeout, message & rejectOnTimeout: * * await pTimeout(promise, { timeout, message, rejectOnTimeout }) * * message and rejectOnTimeout are optional. */ interface pTimeoutOpts { timeout?: number; message?: string; rejectOnTimeout?: boolean; } type pTimeoutArgs = [timeout?: number, message?: string] | [pTimeoutOpts]; export declare function pTimeout(promise: Promise, ...args: pTimeoutArgs): Promise; /** * Wait until a condition is true * @param condition - wait until this callback function returns true * @param timeOutMs - stop waiting after that many milliseconds, -1 for disable * @param pollingIntervalMs - check condition between so many milliseconds * @param failedMsgFn - append the string return value of this getter function to the error message, if given * @return the (last) truthy value returned by the condition function */ export declare function until(condition: MaybeAsync<() => boolean>, timeOutMs?: number, pollingIntervalMs?: number, failedMsgFn?: () => string): Promise; export declare const withThrottling: (fn: (...args: any[]) => Promise, maxInvocationsPerSecond: number) => (...args: any[]) => Promise; export declare const tryInSequence: (fns: ((...args: any[]) => Promise)[]) => Promise; export {};