From: [email protected] [[email protected]]
> 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.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss