async generator を使うとよさそうなことに気づいた
いかにもこれのためにあるって感じがするくらいにマッチしてるけど当たり前の組み合わせだったり?
const wait1Sec = () => new Promise(r => setTimeout(r, 1000))
async function* aGen() {
await wait1Sec()
yield 1
await wait1Sec()
yield 2
await wait1Sec()
yield 3
}
for await (const v of aGen()) {
console.log(v)
}
// 23:36:18.863 1
// 23:36:19.864 2
// 23:36:20.865 3