The current (and likely final) async/await proposal awaits promises and desugars into something like bluebird's Promise.coroutine
with await
playing the part of yield
.
This makes sense, as promises represent a value + time and you're waiting for that value to become available. Note await
also waits for promise like constructs in all other languages that include it like C# or Python (3.5+) .
Note that converting callback APIs to promises is very easy, and some libraries offer tools to do so in a single command. See How to convert an existing callback API to promises for more details.
then
method of unknown functionality and origin. – GroupiePromise.resolve
will be called on the value so plain values will remain plain values and thenables will be converted to promises in a safe way. Athen
able means you can assimilate promises from different libraries inawait
. – Legality