/** * Utilities for polling operations */ type ConditionFunction = (result: T) => boolean; type IntervalFunction = (result: T) => number; type ErrorHandlerFunction = (error: Error) => number | null; type RetryCallback = (result: T, attempt: number) => void; /** * Configuration options for the poll function. */ export interface PollOptions { /** Async function that performs the operation to be polled */ fn: () => Promise; /** Function that evaluates if the polling should continue */ condition: ConditionFunction; /** Maximum number of polling attempts (undefined for infinite) */ maxAttempts?: number; /** Maximum total time to poll in seconds (undefined for infinite) */ timeoutSeconds?: number; /** Time between polls in seconds, or function that returns interval */ intervalSeconds?: number | IntervalFunction; /** Optional callback for each retry attempt */ onRetry?: RetryCallback; /** Optional callback for handling exceptions during polling */ errorHandler?: ErrorHandlerFunction; } /** * Asynchronously polls an operation until a condition is met or timeout/max attempts are reached. * * @param options - Configuration options for polling * @returns The result of the operation once condition is met * @throws Error if maxAttempts is reached * @throws Error if timeoutSeconds is reached * * @example * ```typescript * const result = await poll({ * fn: () => fetchData(), * condition: (result) => result.status === 'completed', * maxAttempts: 5, * timeoutSeconds: 60, * intervalSeconds: 2 * }); * ``` */ export declare function poll(options: PollOptions): Promise; export {}; //# sourceMappingURL=polling.d.ts.map