await* and parallelism
In generators, both
yield*can be used. In async
awaitis allowed. The direct analogoue of
does not make sense in async functions because it would need to
repeatedly await the inner operation, but does not know what value to
pass into each await (for
yield*, it just passes in undefined
because iterators do not accept incoming values).
It has been suggested that the syntax could be reused for different
semantics – sugar for
Promise.all. This would accept a value that is
an array of Promises, and would (asynchronously) return an array of
values returned by the promises. This is expected to be one of the
most common Promise-related oprerations that would not yet have syntax
sugar after the core of this proposal is available.
async / await提议是最小的,只引入必要的原语.关于可能的扩展没有自行决定,应该单独讨论.