@newdash/newdash
Version:
javascript/typescript utility library
16 lines (15 loc) • 576 B
TypeScript
import type { PromiseExecutor } from "./types";
/**
* create a promise with timeout, if time is up but no result/error resolved by promise, will throw an error
*
* @param executor the promise executor
* @param timeout the timeout in milliseconds, e.g. 10000 means 10 seconds, and default value is 60 seconds
*
* @category Async
* @since 5.14.0
*
* @throws {TimeoutError}
*/
export declare function createTimeoutPromise<T>(executor: PromiseExecutor<T>, timeout?: number): Promise<T>;
export declare const timeout: typeof createTimeoutPromise;
export default timeout;