parallel-universe
Version:
The set of async flow control structures and promise utils.
13 lines (12 loc) • 759 B
TypeScript
import { AbortablePromise } from './AbortablePromise';
import { AbortableCallback } from './types';
/**
* Returns a promise that is fulfilled with a produced value, or rejected after the timeout elapses.
*
* @param cb A callback that receives a signal that is aborted if the timeout elapses, or a promise-like object.
* @param ms The timeout after which the returned promise is rejected.
* @returns The promise that is fulfilled before a timeout elapses, or rejected with a
* {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#timeouterror TimeoutError}.
* @template T The value returned from the callback or promise.
*/
export declare function timeout<T>(cb: AbortableCallback<T> | PromiseLike<T>, ms: number): AbortablePromise<T>;