Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/playerony/try-catch-wrapper
Functional try-catch wrapper.
https://github.com/playerony/try-catch-wrapper
javascript react-try-catch try-catch try-catch-wrapper typescript typescript-library
Last synced: 4 days ago
JSON representation
Functional try-catch wrapper.
- Host: GitHub
- URL: https://github.com/playerony/try-catch-wrapper
- Owner: playerony
- Created: 2021-09-04T17:11:14.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-06T17:16:38.000Z (over 3 years ago)
- Last Synced: 2024-11-16T21:16:11.113Z (about 2 months ago)
- Topics: javascript, react-try-catch, try-catch, try-catch-wrapper, typescript, typescript-library
- Language: TypeScript
- Homepage:
- Size: 103 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# try catch wrapper
![Lint](https://github.com/playerony/try-catch-wrapper/workflows/lint/badge.svg)
![Test](https://github.com/playerony/try-catch-wrapper/workflows/test/badge.svg)
![Build](https://github.com/playerony/try-catch-wrapper/workflows/build/badge.svg)
![Prettier](https://github.com/playerony/try-catch-wrapper/workflows/prettier/badge.svg)
![Typecheck](https://github.com/playerony/try-catch-wrapper/workflows/typecheck/badge.svg)
![Commitlint](https://github.com/playerony/try-catch-wrapper/workflows/commitlint/badge.svg)Functional try-catch wrapper.
- [API Docs](https://playerony.github.io/try-catch-wrapper)
# Installation ([npm](https://www.npmjs.com/package/@playerony/try-catch-wrapper))
```
npm i @playerony/try-catch-wrapper
``````
yarn add @playerony/try-catch-wrapper
```# Usage
```js
import { tryCatchWrapper, asyncTryCatchWrapper } from '@playerony/try-catch-wrapper';const onSuccess = () => console.log('success');
const asyncOnSuccess = async () => Promise.resolve(10);
const onError = () => console.log('error');
tryCatchWrapper(onSuccess, onError);
asyncTryCatchWrapper(asyncOnSuccess, onError);
```