@vgerbot/async
    Preparing search index...

    Function each

    • Iterates over a collection asynchronously for side effects.

      Type Parameters

      • I

        Item/value type in the collection.

      Parameters

      • data: I[] | Promise<I[]>

        Input array/object, or a promise that resolves to one.

      • iterator: (item: I, token: CancellableToken) => Promise<void>

        Async callback invoked for each item/value.

      • Optionaloptions: EachOptions

        Configuration options, including cancellation and concurrency.

      Returns CancellableHandle<void>

      A cancellable handle that resolves when iteration completes.

      const handle = each(
      [1, 2, 3],
      async (item, token) => {
      await token.sleep(5);
      console.log(item);
      },
      { concurrency: 2 },
      );

      await handle;
      const handle = each(
      { a: 1, b: 2 },
      async (value, key) => {
      console.log(key, value);
      },
      );

      await handle;
    • Iterates over a collection asynchronously for side effects.

      Type Parameters

      • I

        Item/value type in the collection.

      Parameters

      • data: CollectionInput<I> | Promise<CollectionInput<I>>

        Input array/object, or a promise that resolves to one.

      • iterator: (item: I, key: string | number, token: CancellableToken) => Promise<void>

        Async callback invoked for each item/value.

      • Optionaloptions: EachOptions

        Configuration options, including cancellation and concurrency.

      Returns CancellableHandle<void>

      A cancellable handle that resolves when iteration completes.

      const handle = each(
      [1, 2, 3],
      async (item, token) => {
      await token.sleep(5);
      console.log(item);
      },
      { concurrency: 2 },
      );

      await handle;
      const handle = each(
      { a: 1, b: 2 },
      async (value, key) => {
      console.log(key, value);
      },
      );

      await handle;