https://github.com/timwis/eres
Use async/await with [err, result] instead of try/catch.
https://github.com/timwis/eres
Last synced: 4 months ago
JSON representation
Use async/await with [err, result] instead of try/catch.
- Host: GitHub
- URL: https://github.com/timwis/eres
- Owner: timwis
- Created: 2017-08-12T20:46:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-13T13:45:31.000Z (over 8 years ago)
- Last Synced: 2025-04-04T05:23:16.434Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 62
- Watchers: 1
- Forks: 11
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# eres
Use async/await with `[err, result]` instead of try/catch.
## usage
Instead of:
```javascript
let result
try {
result = await fetch('https://...')
} catch (err) {
console.error('no workie')
}
render(result)
```
You can now:
```javascript
const [err, result] = await eres(fetch('https://...'))
if (err) return console.error('no workie')
render(result)
```
Don't spend all the vertical space you get back in one place.
## installation
```bash
npm install eres
```
## related
- [0x00A/asde](https://www.npmjs.com/package/asde)