@vgerbot/async
    Preparing search index...

    Function parallel

    • Executes an array of tasks concurrently, with an optional concurrency limit. Resolves with an array of results in the same order as the input tasks. If any task rejects, the entire operation rejects.

      Parameters

      • options: ParallelOptions

        Configuration options, including cancellation token and concurrency limit.

      • ...tasks: AsyncTask<unknown>[]

        The tasks to execute.

      Returns CancellableHandle<unknown[]>

      A cancellable handle that resolves with the array of task results.

      const handle = parallel(
      { concurrency: 2 },
      async (token) => {
      await token.sleep(30);
      return "A";
      },
      async (token) => {
      await token.sleep(10);
      return "B";
      },
      );

      const result = await handle; // ["A", "B"]