nsuite / withTimeout
Function: withTimeout()
withTimeout<
T>(promise,timeoutMs?):Promise<T>
Defined in: UtilsPromise.ts:20
Wraps a promise with a timeout. If the promise does not resolve or reject within the specified time, it will be rejected with a ${TIMEOUT_ERROR_MESSAGE} error.
Type Parameters
T
T
Parameters
promise
Promise<T>
The promise to wrap with a timeout.
timeoutMs?
number = DEFAULT_PROMISE_TIME_OUT
The timeout duration in milliseconds.
Returns
Promise<T>
A new promise that either resolves with the original promise's value or rejects with a timeout error if the timeout duration is exceeded.
Example
ts
import { withTimeout } from "nsuite";
const newPromise = withTimeout(promise, 3000);