⚽ catches
Some functions throw errors. Maybe you don't care about any errors. The show must go on.
Maybe you do this:
let data: string | undefined
try {
data = getSomeString()
} catch () {
}
That's a lot of lines.
We can do better
Introducing catches
const data = catches(getSomeString)
It's that easy
There's more!
const data = catches(getSomeString) ?? "fallback"
const data = await catches(async () => "...") ?? "fallback"
const data = catches(getSomeString, 1, 2)
Installation
npm install catches
bun i catches
yarn add catches
pnpm i catches
oro add catches
Contributing
I mean. It's kinda done right? There's nothing left here. Stop reading, go use catches
, save yourself some time, spend it with your family. You won't get this time back. I'm serious. Look outside. What a beautiful day. Now look at this README. Do you really want to contribute to this? I mean...
But no, seriously. If you do want to contribute. Please do. I'd love that.
License
This project is licensed under the GPL v3 or Later.