UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

23 lines (22 loc) 585 B
import { AsyncFunction } from "../types"; /** * wrap an async function with timeout * * @since 5.15.0 * @category Async * * @param runner async runner please, otherwise the `timeout` is not meaningful * @param timeout timeout threshold in milliseconds, default value is 60 seconds * * @throws {TimeoutError} * * @example * * ```ts * const f = timeout(async() => {}, 1000) * // f() will throw error if the result is not resolved in one second * ``` * */ export declare function timeout<T extends AsyncFunction>(runner: T, timeout?: number): T; export default timeout;