typecatch-neverthrow
v0.0.1
Published
Simple TypeScript tryCatch util function for both sync and async using neverthrow
Readme
typecatch
Simple TypeScript tryCatch util function for both sync and async using neverthrow
Installation
npm i typecatch-neverthrowUsage
import { tryCatch } from "typecatch";
// function:
const data = tryCatch(() => JSON.parse(/* ... */));
if (!data.isErr()) {
// do stuff
}
// promise:
const res = await tryCatch(fetch(/* ... */));
if (!res.isErr()) {
// do stuff
}