• Adds a timeout to a promise and rejects if the specified timeout has elapsed. Also rejects if the specified promise rejects, and resolves if the specified promise resolves.

    NOTE: this operation will continue even after it throws a TimeoutError.

    Type Parameters

    • T

    Parameters

    • promise: Promise<T>

      promise to use with timeout.

    • timeout: number

      the timeout in milliseconds until the returned promise is rejected.

    Returns Promise<T>