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