Saltar al contenido principal

Opciones

  • concurrency: límite de tareas simultáneas
  • mode: en runAll, settle o fail-fast

runAll con límite

import { runAll } from "trybox";

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

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

fail-fast

Detiene el inicio de nuevas tareas al primer error.
const results = await runAll<number>(tasks, {
  concurrency: 4,
  mode: "fail-fast",
});
Las tareas no iniciadas quedan en estado skipped.

runAllOrThrow

Lanza al primer error y respeta concurrency.
import { runAllOrThrow } from "trybox";

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