await-go
v1.0.0
Published
let es6 async/await error handler like go
Downloads
3
Readme
go.js
let es6 async/await error handler like go
install
yarn add @hufeng/go.js
why?
usage?
import go from ‘@hufeng/go.js'
function test() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('hello');
//reject(new Error('error'))
}, 200);
});
}
(async () => {
let { res, err } = await go(test());
console.log(res); // hello
console.log(err); //Error('error')
({ res, err } = await go(test()));
console.log(res); // hello
console.log(err); //Error('error')
})();