yield* behavior on last iterator result
GeorgNeis opened this issue · 5 comments
yield* foo
awaits on the value
component of each result of foo
, except for the last one (the one whose done
component is true). I'm unsure if this is intended or a bug. If it is intended, I think it's worth having an explicit note about it in the spec.
@ajklein: FYI
I'm going to go with "intended". The protocol intentionally ignores any last values.
Oh, no, I forgot, the completion value of yield*
is the last value. OK, so that's a bug.
where does yield*
await on "value" for not-last ones ?
Via GeneratorYield
, yield*
passes such a value to AsyncGeneratorResolve
, which resolves a new promise with it:
Perform ! Call(valueWrapperCapability.[[Resolve]], undefined, « value »).
It then feeds this promise into the result promise from the queue:
Perform ! PerformPromiseThen(valueWrapperCapability.[[Promise]], onFulfilled, undefined, promiseCapability).
In the case where value
is itself a promise, this has the effect of yield*
awaiting on it.