• Wraps a promise with a timeout. If the promise does not resolve or reject within the specified time, the promise will reject with a TimeoutError.

    Type Parameters

    • T

    Parameters

    • promise: Promise<T>

      The promise to wrap.

    • ms: number

      The number of milliseconds to wait before timing out.

    • Optional message: string

      Optional error message to use when the promise times out.

    Returns Promise<T>

    A new promise that resolves or rejects with the same value as the original promise, or rejects with a TimeoutError if the promise times out.