Function timeout

  • Returns a promise that is fulfilled with a produced value, or rejected after the timeout elapses.

    Type Parameters

    • T

      The value returned from the callback or promise.

    Parameters

    • cb: AbortableCallback<T> | PromiseLike<T>

      A callback that receives a signal that is aborted if the timeout elapses, or a promise-like object.

    • ms: number

      The timeout after which the returned promise is rejected.

    Returns AbortablePromise<T>

    The promise that is fulfilled before a timeout elapses, or rejected with a TimeoutError.