• Races a promise with a timeout, rejecting with a TimeoutError if the timeout is reached before the provided promise.

    Type Parameters

    • T

    Parameters

    • promise: PromiseLike<T>

      The promise to race against a timeout.

    • Optionaltime: number

      The number of seconds to wait. If undefined, the promise is returned without wrapping.

    • message: string = DEFAULT_TIMEOUT_MESSAGE

      The message to set in the TimeoutError.

    Returns Promise<T>