Saltar al contenido principal

De try/catch a run

import { run } from "trybox";

const r = await run(() => fetch("/api").then((x) => x.json()));
if (r.ok) {
  console.log(r.data);
} else {
  console.error(r.error.code);
}

De Promise.all a runAll

import { runAll } from "trybox";

const tasks = [() => fetch("/a"), () => fetch("/b")];
const results = await runAll<Response>(tasks, {
  concurrency: 2,
  mode: "settle",
});