try-function
v0.1.0
Published
TODO
Downloads
4
Readme
try-function
Installation
npm install try-function
Usage
Convert this:
let payload: string | undefined;
try {
payload = decode("abc123");
} catch (error) {
// ...
}
... to this:
const payload = tryFn(
() => decode("abc123"),
(error) => {
// ...
}
);
- Functional with no re-assignement (no need for
let
) - Less error-prone
- Automatic typing (no need to define
result
's type) - Supports
async
functions out-of-the-box - Supports
finally
blocks - No dependencies
- Fully tested
Changelog
For a list of changes and releases, see the changelog.
Contributing
Found a bug, have a question or looking to improve try-function? Open an issue, start a discussion or submit a PR!