https://github.com/klipitkas/await-to
Solve the try-catch hell using golang style error handling.
https://github.com/klipitkas/await-to
hell js try try-catch trycatch
Last synced: 3 months ago
JSON representation
Solve the try-catch hell using golang style error handling.
- Host: GitHub
- URL: https://github.com/klipitkas/await-to
- Owner: klipitkas
- Created: 2021-09-23T20:29:50.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T11:32:02.000Z (over 2 years ago)
- Last Synced: 2025-01-21T07:11:21.199Z (4 months ago)
- Topics: hell, js, try, try-catch, trycatch
- Language: JavaScript
- Homepage:
- Size: 290 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# await-to
Solve the try-catch hell using golang style error handling.
## Install
npm i @klipitkas/await-to --save
## Usage
```js
import { to } from 'await-to';const doSomething = () => {
const [ data, error ] = await to(resolveOrRejectSomePromise());if (error) {
throw new Error("Whoops!");
}return data;
}
```## Test
npm run test