Skip to main content

Options

  • concurrency: limit of simultaneous tasks
  • mode: in all, settle or fail-fast

all with limit

import { all } from "tryo";

const tasks = Array.from({ length: 10 }, (_, i) => async () => i);

const results = await all<number>(tasks, { concurrency: 3 });

fail-fast

Stops the start of new tasks on the first error.
const results = await all<number>(tasks, {
  concurrency: 4,
  mode: "fail-fast",
});
Unstarted tasks remain in skipped state.

allOrThrow

Throws on the first error and respects concurrency.
import { allOrThrow } from "tryo";

const data = await allOrThrow<number>(tasks, { concurrency: 2 });