|
|
|
|
|
by gchq-7703
1014 days ago
|
|
I don't believe that's true. Consider this infinite generator: async function* infinite() {
while (1) {
yield 'example'
}
}
(async function () {
for await (const value of infinite()) {
console.log(value)
}
})()
If the generator was consumed all at once, this would never print (because the generator is infinite). `for await... of` should only consume a single step of the stream / generator at a time. It's just syntactic sugar for the usual calls to .next() and etc. See the docs here[0][0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... |
|