tc39 / proposal-async-iteration

Asynchronous iteration for JavaScript
https://tc39.github.io/proposal-async-iteration/
MIT License
859 stars 44 forks source link

add (corrected) for-await-of equivalent example #129

Open shaunlebron opened 6 years ago

shaunlebron commented 6 years ago

Fixed #128 if the correct translated example is desired:


Original example:

for await (const line of readLines(filePath)) {
  console.log(line);
}

Equivalent to:

const i = readLines(filePath);
while (true) {
  const {value, done} = await i.next();
  if (done) break;
  console.log(value);
}