Example 1 — Await then yield
Wait before producing.
JavaScript
async function* g() {
const v = await Promise.resolve(9);
yield v;
}
(async () => { for await (const x of g()) console.log(x); })();How It Works
- Await inside the generator.
- Then yield the result.
