Node.js · Middle · Question 15 of 75
How can you read a readable stream line by line or chunk by chunk with async/await?
- 1Only with the
dataevent - ✓Correct answer: With
for await (const chunk of stream) - 3With
stream.forEach(await)
Explanation
Readable streams are async iterables. For lines, combine it with readline.createInterface({ input: stream }), which is also async iterable.