ts-prime
Version:
A utility library for JavaScript and Typescript.
17 lines • 780 B
TypeScript
/**
* Prevents promise to execute longer than X ms
* @param fn The function to invoke.
* @param maxDuration - Duration in milliseconds
* @throws If provided function executes longer than `maxDuration` milliseconds
* @signature
* P.timeout(fn, milliseconds)
* @signature
* P.timeout(milliseconds)(fn)
* @example
* const req = P.timeout(request, 500)
* req({ ... }) // Will throw if function executes longer than 500ms
* @category Utility, Pipe
*/
export declare function timeout<I extends any[], R>(fn: (...args: I) => Promise<R>, maxDuration: number): (...args: I) => Promise<R>;
export declare function timeout<I extends any[], R>(maxDuration: number): (fn: (...args: I) => Promise<R>) => (...args: I) => Promise<R>;
//# sourceMappingURL=timeout.d.ts.map