ES6,ES7,ES8 and beyond. A Proposed Roadmap.

Domenic Denicola domenic at domenicdenicola.com
Mon Apr 22 14:51:53 PDT 2013


From: samth0 at gmail.com [samth0 at gmail.com]

> What exactly would be the semantic difference between this and just using 'yield'?

You mean, if you replaced my example by

```js
function*^ doubleSomeNumbers() {
  const numbers = yield getNumbersToDouble();

  for (var i = 0; i < numbers.length; ++i) {
    yield numbers[i] * 2;
  }
}
```

?

My thinking was that `function*` returns a generator, `function^` returns a promise, and `function*^` returns a promise for a generator. Thus:

- The original version from my previous message returns a promise for a generator that yields a sequence of doubled numbers, which settles only after waiting for the promise returned from `getNumbersToDouble` to settle (and will reject if that promise rejects`).
- Whereas, this new version returns a promise that is always fulfilled, immediately (since there's no `await` or explicit promise-working). Its fulfillment value is a generator which first yields the promise returned by `getNumbersToDouble`, then yields the doubled numbers.



More information about the es-discuss mailing list