@vgerbot/async
    Preparing search index...

    Function times

    • Repeats an async iterator count times and collects results in index order.

      Type Parameters

      • R

        Iterator return type.

      Parameters

      • count: number

        Number of iterations to run. Values <= 0 return an empty array.

      • iterator: (index: number, token: CancellableToken) => Promise<R>

        Async iterator receiving the current index and cancellation token.

      • Optionaloptions: TimesOptions<R>

        Configuration options, including cancellation and concurrency.

      Returns CancellableHandle<R[]>

      A cancellable handle that resolves to collected results.

      const handle = times(
      4,
      async (index, token) => {
      await token.sleep(10);
      return index * index;
      },
      { concurrency: 2 },
      );

      const result = await handle; // [0, 1, 4, 9]