Loops over a generator until it finishes, calling callback. Useful if you don't care about the value generator produces, just the number of loops.

In this version, we do a for await of over gen, and also await callback().

await until(count(5), () => {
// do something 5 times
});

If you want the value from the generator, use a for of loop as usual.

If callback explicitly returns false, the generator is aborted.

  • Parameters

    • it: Iterable<any> | AsyncIterable<any>

      Generator to run

    • callback: (() =>
          | undefined
          | boolean
          | void
          | Promise<undefined>
          | Promise<void>
          | Promise<boolean>)

      Code to call for each iteration

        • ():
              | undefined
              | boolean
              | void
              | Promise<undefined>
              | Promise<void>
              | Promise<boolean>
        • Returns
              | undefined
              | boolean
              | void
              | Promise<undefined>
              | Promise<void>
              | Promise<boolean>

    Returns Promise<undefined>