Socket
Socket
Sign inDemoInstall

await-catch

Package Overview
Dependencies
4
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    await-catch

Async await wrapper for easy error handling


Version published
Maintainers
1
Install size
2.70 MB
Created

Readme

Source

Await-catch

NPM version Downloads Build Status

Async await wrapper for easy error handling

This library is inspired by Dima Grossman && Tomer Barnea work. For more info about this approach, please check these links

Install

npm i await-catch --save

Usage

With just one promise call:

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:

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

License

MIT © Cristian Buffa

Keywords

FAQs

Last updated on 28 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc