async function* nums() { yield 1; yield 2; } const out = []; for await (const n of nums()) out.push(n); console.log(out);