aplus-await
A simple way of handling async/await responses with array destructuring. The original concept for this package was derived from Promises/A+.
Install
$ yarn add aplus-await
Usage
// Instead of writinglet result;try result = await ; catch error throw error;console; // You can writeconst result error = await ;if error throw error;console;
API
When you wrap a promise with aplusAwait
, you are guaranteed to be returned two arguments in the form of an array. The first element is the response of the promise and the second element is any error that occurred while executing the promise.
If you do not care about the error:
const result = await ;
If you just want the error:
const error = await ;
If you do not want to use array destructuring:
const response = await ;// response[0] = result// response[1] = error
License
MIT © Henry Kaufman