I'm looking for something that, with any version of babel, can simply translate async/await into Promises in a human-readable form - no any extra helpers or prototypes, etc.
Example In:
async function doStuff() {
var x = await foo();
var y = await bar(x);
return y;
}
console.log(await doStuff());
I've been trying the different examples in the README, but even with promise: true it seems that $asyncbind and trampoline, etc get added.
~Also, it seems to use new Promise(function ($return, $error) {}) rather than Promise().resolve(function () {}), which seems like it would lead to thrown errors not being caught. Or maybe async/await doesn't actually handle errors the way I thought it does...~
Apparently new Promise(function (resolve, reject) { ... }) catches exceptions now... or maybe it always did and I'm getting confused about it's inability to handle a returned promise with a rejection
I'm looking for something that, with any version of babel, can simply translate async/await into Promises in a human-readable form - no any extra helpers or prototypes, etc.
Example In:
Example Out:
Is this tool capable of that?
I've been trying the different examples in the README, but even with
promise: true
it seems that$asyncbind
andtrampoline
, etc get added.~Also, it seems to use
new Promise(function ($return, $error) {})
rather thanPromise().resolve(function () {})
, which seems like it would lead to thrown errors not being caught. Or maybeasync
/await
doesn't actually handle errors the way I thought it does...~Apparently
new Promise(function (resolve, reject) { ... })
catches exceptions now... or maybe it always did and I'm getting confused about it's inability to handle a returned promise with a rejection