Let async generators directly await an incoming promise
Isiah Meadows
isiahmeadows at gmail.com
Mon Apr 1 12:01:36 UTC 2019
Filed https://github.com/tc39/ecma262/issues/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
On Mon, Apr 1, 2019 at 7:00 AM Simo Costa <andrysimo1997 at gmail.com> wrote:
>
> 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
> }
> }
> ```
>
>
>
>
> Mail priva di virus. www.avast.com
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
More information about the es-discuss
mailing list