tryCatch
import { tryCatch } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/async.ts";Wrap a function that can throw in a try/catch block, returning an Async.
@example
import { tryCatch } from "./async.ts";
const riskyFunction = (n: number) => {
if (n < 0) throw new Error("Negative number");
return n * 2;
};
const safe = tryCatch(riskyFunction, (e, args) => 0);
const result1 = await safe(5)(); // 10
const result2 = await safe(-1)(); // 0
function tryCatch<AS extends unknown[], A>(fasr: (...as: AS) => A | PromiseLike<A>, onThrow: (e: unknown, as: AS) => A): (...as: AS) => Async<A>;