Skip to main content

withTimeout

@webda/bench


Function: withTimeout()

withTimeout<T>(promise, ms): Promise<T | undefined>

Defined in: packages/bench/src/stats.ts:220

Wait for a promise, at most a delay

The timer is cleared once the promise settles, so no timer outlives the wait.

Type Parameters​

T​

T

Parameters​

promise​

Promise<T>

the promise

ms​

number

maximum wait in milliseconds

Returns​

Promise<T | undefined>

the value of the promise, undefined on timeout or rejection