tryThunk
import { tryThunk } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/fn.ts";Wrap a thunk (a Fn that takes no arguments) in a try catch block, using an onThrow function (that should itself never throw) to handle a default case should the original function throw. This is useful for wrapping functions that might throw.
@example
import * as F from "./fn.ts";
const getZero = (): number => {
if (Math.random() > 0.5) {
throw new Error("Too high!");
}
return 0;
}
const result = F.tryThunk(getZero, () => 0); // 0