# await-catch

> Async await wrapper for easy error handling

Latest version **1.6.7** (published 2018-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install await-catch
pnpm add await-catch
yarn add await-catch
bun add await-catch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.7 |
| Published | 2018-05-28 |
| First published | 2018-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Cristian Buffa |
| Maintainers | bufface |
| Keywords | async-await, async, await, try-catch, try, catch, es6, promise |

## Links

- npm: https://www.npmjs.com/package/await-catch
- Repository: https://github.com/bufface/await-catch
- Issues: https://github.com/bufface/await-catch/issues
- npm.io page: https://npm.io/package/await-catch

## Dependencies (1)

- [babel-polyfill](https://npm.io/package/babel-polyfill.md) ^6.26.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.6.7 (latest) — 2018-05-28
- 1.6.6 — 2018-05-28
- 1.6.5 — 2018-03-03
- 1.6.2 — 2018-02-19
- 1.5.2 — 2018-02-19
- 1.4.2 — 2018-02-19
- 1.4.1 — 2018-02-16
- 1.3.1 — 2018-02-16
- 1.2.1 — 2018-02-16
- 1.1.1 — 2018-02-16
- 1.1.0 — 2018-02-16
- 1.0.0 — 2018-02-16

## README

# Await-catch

[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url]

Async await wrapper for easy error handling
> _This library is inspired by [Dima Grossman](http://blog.grossman.io) && Tomer Barnea work. For more info about this approach, please check these links_
> * [_How to write async await without try-catch blocks in Javascript_](https://blog.grossman.io/how-to-write-async-await-without-try-catch-blocks-in-javascript/)

## Install

```sh
npm i await-catch --save
```

## Usage

*With just one promise call:*
```javascript
import to from 'await-catch';

async function asyncTask(values) {
     let err, user;

     [ err, user ] = await to(userPromise(values));
     if(err) throw new Error('Some awesome Error message.');

     return user;
}
```

*It works with an array of promises too:*

```javascript
import to from 'await-catch';

async function asyncTasks(params) {
  let err, result;

  [ err, result ] = await to([ userPromise(), tasksByUserPromise(params) ]);
  if (err) throw new Error('Some awesome Error message.');

  return result;
}
```

## Contributors

* [Fedeorlandau](https://github.com/Fedeorlandau)


## License

MIT © [Cristian Buffa](https://github.com/bufface)

[downloads-image]: https://img.shields.io/npm/dt/await-catch.svg

[npm-url]: https://www.npmjs.com/package/await-catch
[npm-image]: http://img.shields.io/npm/v/await-catch.svg

[travis-url]: https://travis-ci.org/bufface/await-catch
[travis-image]: https://api.travis-ci.org/bufface/await-catch.svg?branch=master

---
_Source: https://npm.io/package/await-catch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
