Let async generators directly await an incoming promise
Simo Costa
andrysimo1997 at gmail.com
Mon Apr 1 10:59:54 UTC 2019
Currently the following illustrative syntax is forbidden:
```js
obj = {
async*[Symbol.asyncIterator]() {
const res = await yield;
// do stuff with res
}
}
```
Used in this way (simple example):
```js
const ait = [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:
```js
obj = {
async*[Symbol.asyncIterator]() {
const p = yield;
const res = await p;
// do stuff with res
}
}
```
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Mail
priva di virus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190401/14018efb/attachment.html>
More information about the es-discuss
mailing list