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