From try/catch to run
Copy
import { run } from "tryo";
const r = await run(() => fetch("/api").then((x) => x.json()));
if (r.ok) {
console.log(r.data);
} else {
console.error(r.error.code);
}
From Promise.all to all
Copy
import { all } from "tryo";
const tasks = [() => fetch("/a"), () => fetch("/b")];
const results = await all<Response>(tasks, {
concurrency: 2,
mode: "settle",
});