• Invokes a callback periodically with the given delay between fulfillment of returned promises until the condition is met. If callback throws an error or returns a rejected promise, then the promise returned from repeat is rejected.

    Type Parameters

    • I

      The value returned by the callback.

    • O

      The value that fulfills the returned promise.

    Parameters

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

      The callback that is periodically invoked.

    • ms: undefined | 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 result and returns the delay. If omitted then delay is 0.

    • until: ((value, index) => value is O)

      The callback that should return true to terminate the loop, or false to proceed to the next iteration. The condition is checked before the next iteration is scheduled. If omitted then loop is repeated indefinitely.

        • (value, index): value is O
        • Parameters

          • value: I
          • index: number

          Returns value is O

    Returns AbortablePromise<O>

    The promise that is fulfilled with the callback result.

    See

    retry

  • Invokes a callback periodically with the given delay between fulfillment of returned promises until the condition is met. If callback throws an error or returns a rejected promise, then the promise returned from repeat is rejected.

    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 result and returns the delay. If omitted then delay is 0.

    • Optional until: ((value, index) => unknown)

      The callback that should return truthy value to terminate the loop, or falsy to proceed to the next iteration. The condition is checked before the next iteration is scheduled. If omitted then loop is repeated indefinitely.

        • (value, index): unknown
        • Parameters

          • value: T
          • index: number

          Returns unknown

    Returns AbortablePromise<T>

    The promise that is fulfilled with the callback result.

    See

    retry