Function waitFor

  • Polls the callback until it returns a truthy value or rejects.

    Type Parameters

    • T

      The value returned by the callback.

    Parameters

    • cb: ((signal, index) => Awaitable<T>)

      The callback that is periodically invoked.

    • Optional ms: number | ((value, index) => number)

      The number of milliseconds between the settlement of the last promise returned by the callback and the next invocation. Or a callback that receives the latest value and returns the delay. If omitted then delay is 0.

    Returns AbortablePromise<Exclude<T, false | 0 | "" | null | undefined>>

    The truthy value.