Comments
@Gvozd Hmm, Safari Technical Preview the same result as in Chrome Canary. As I know https://tc39..io/proposal-async-iteration/#sec-asyncgeneratoryield 11.4.3.7.8.b
|
@gskachkov Thanks It seems that Async Generator Rewrite is not entirely actual. Also after read slide 27, I got additional code with problem behavior (async () => {
const iterator = {
i: 0,
next() {
if (this.i >= 3) {
return {done: true};
}
return {
value: Promise.resolve(this.i++),
done: false
};
},
[Symbol.asyncIterator]() {
return this;
}
};
for await(const i of iterator) {
console.log(i);
}
})(); babel-node execution log - not correct for slide 27
Chrome Canary log - correct for slide 27
|
@Gvozd This has been fixed in Babel 7 (currently Beta) so Babel's implementation should be compliant with the other implementations now. |
@Gvozd I'm receiving following results in Safari Technical Preview:
|
@Jamesernator I check with Also I was surprised, that .babelrc {
"presets": [
["@babel/env", {
"targets": {
"node": "current"
},
"include": [
// without this `for-await` not worked !!!
"transform-async-to-generator"
]
}],
"@babel/stage-0"
]
} |
@caitp Good to know! I thought I had to wait for node to use 6.3 before I could get at this goodness! |
@gskachkov Thanks for your help |
Its out-of-dateness was causing confusion; see #117 for an example.
@domenic AsyncGeneratorRewrite.md is good idea - for me it was more understandable than spec |
I try code below in
babel-node
, andChrome Canary(v64)
, and get different resultUnfortunately I could not understand what behavior is correct by this spec
In this example I call
iterator.next()
twice, and synchronouslypoint#2
andtask#2
will be called immediately(within seconditerator.next()
), because there is noawait
for thetask#1
I give this behavior at
babel-node
, but not inChrome Canary
Chrome execute
point#2
only whentask#1
resolved, like as I wroteyield await task('task#1')
insteadyield task('task#1')
promiseCapability/IteratorResult
be resolved only when theresult
is resolved, and contain resolved value?2.1) In
babel-node
IteratorResult
resolved, whenyield
got the value(pending Promise), and return this value without additional awaiting.In other word IteratorResult..value can be a
Promise
2.2) In
Chrome
IteratorResult
resolved, whenyield
got the value(pending Promise), and this value also resolved.In other word IteratorResult..value cannot be a
Promise
- it is always fulfilled valueI read "Async Generator Rewrite", and it turns out that the behavior of the
babel
is correctBut when I read #114, I'm confused
What is correct behavior for this example?
babel-node execution log
Chrome Canary execution log
The text was updated successfully, but these errors were encountered: