Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4433263
repro_async_generator_await_yield.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
repro_async_generator_await_yield.cjs
View Options
function assert(cond, msg) {
if (!cond) throw new Error(msg);
}
async function* delayedSingle() {
await Promise.resolve();
yield 42;
}
async function* delayedDouble() {
await Promise.resolve();
yield 1;
await Promise.resolve();
yield 2;
}
async function main() {
{
const it = delayedSingle();
const first = await it.next();
console.log("single:first", JSON.stringify(first));
assert(first.done === false, "single first result should not be done");
assert(first.value === 42, "single first result should yield 42");
}
{
const it = delayedDouble();
const first = await it.next();
const second = await it.next();
const third = await it.next();
console.log(
"double",
JSON.stringify(first),
JSON.stringify(second),
JSON.stringify(third),
);
assert(first.done === false, "double first result should not be done");
assert(first.value === 1, "double first result should yield 1");
assert(second.done === false, "double second result should not be done");
assert(second.value === 2, "double second result should yield 2");
assert(third.done === true, "double third result should be done");
}
console.log("async generator await+yield repro passed");
}
main().catch((err) => {
console.error(err && err.stack ? err.stack : String(err));
throw err;
});
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, May 2, 5:32 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
543038
Default Alt Text
repro_async_generator_await_yield.cjs (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment