Simple TypeScript tryCatch util function for both sync and async
npm i typecatch
import { tryCatch } from "typecatch";
// function:
const { data, error } = tryCatch(() => JSON.parse(/* ... */));
// promise:
const { data, error } = await tryCatch(fetch(/* ... */));