Let async generators directly await an incoming promise
# Isiah Meadows (6 years ago)
Filed tc39/ecma262#1497 to track this. Sounds to me like a spec bug.
Isiah Meadows contact at isiahmeadows.com, www.isiahmeadows.com
Isiah Meadows contact at isiahmeadows.com, www.isiahmeadows.com
Currently the following illustrative syntax is forbidden:
let obj = { async*[Symbol.asyncIterator]() { const res = await yield; // do stuff with res } }
Used in this way (simple example):
const ait = obj[Symbol.asyncIterator](); ait.next(); ait.next(p); // p is a Promise
We cannot directly write
await yield
. Is there any particular reason? We have to write:let obj = { async*[Symbol.asyncIterator]() { const res = await (yield); // do stuff with res } }