await-promise-wrapper
v1.0.0
Published
Handelling error without using try/catch, while using await
Downloads
2
Readme
promise-wrapper helps to handle error handel while using await
Using npm:
npm i --save await-promise-wrapper
In Node.js:
const {forThePromise} = require('await-promise-wrapper');
async function job(){
let [err,result] = await forThePromise(somePromise());
if(err){
console.log("err");
}
if(result){
console.log("success");
}
let [err,result] = await forThePromise(54);
// result === 54 (true)
// err === null (true)
let [err,result] = await forThePromise("hello world");
// result === "hello world" (true)
// err === null (true)
}