6.2.1.2 GeneratorYield ( iterNextObj [ , done ] )
...
10. If generatorKind is async,
a. If done is not provided, let done be ? IteratorComplete(iterNextObj).
IteratorComplete(iterNextObj) is done only if done parameter is not passed.
there are only 2 cases that done parameter is not passed.
There iterNextObj parameter is created by CreateIterResultObject, with done==false.
So, it's known that IteratorComplete(iterNextObj) is always false, and it never fail.
Actually, even if done parameter is passed, it's also always false.
That's a good point, we only ever GeneratorYield a result that's not done. So we can actually get rid of IteratorComplete in GeneratorYield and remove the optional argument again.
https://tc39.github.io/proposal-async-iteration/#sec-generatoryield
IteratorComplete(iterNextObj)
is done only ifdone
parameter is not passed. there are only 2 cases thatdone
parameter is not passed.https://tc39.github.io/ecma262/#sec-generator-function-definitions-runtime-semantics-evaluation
There
iterNextObj
parameter is created byCreateIterResultObject
, withdone==false
. So, it's known thatIteratorComplete(iterNextObj)
is alwaysfalse
, and it never fail.Actually, even if
done
parameter is passed, it's also alwaysfalse
.