Async Iterators: A New Future for Streams
summary
Async iterators replace complicated Node streams with concise generator-style code that can read a file, split lines, parse CSV and produce newline-delimited JSON in ~50 lines, implement a pipeline/pipe that accepts async generators, build an HTTP request channel surfer as an async iterator, and batch items by manually calling next. Performance testing shows async iterators about 15% faster and using 40% less memory for a CSV→NDJSON example, but watch out for for-await fully consumes and microtask-priority pitfalls requiring an extra await or setImmediate.
AI-written summary · about
chapters (10)
- 0:00Intro
- 1:47Streams
- 4:01parsing
- 6:40handling streams
- 7:51HTTP servers
- 11:49Batching
- 13:41Yield
- 14:59Pitfalls
- 17:39Desalgo
- 19:22Performance Demo
related talks
23mAsync Iterators: a new future for streams
33mStream into the Future
24mGenerating async iterators is ekstreamly easy, I Promise ;)
28mThe good, the bad and the ugly of nodejs streams
24mAsync and Streaming JS - Are we doing it wrong?
33mTaking Node.js to The Ex-Stream: Stream to Scale
28mWhat happens next: a choose-your-own-adventure with iterators
22mFrom Promises through Generators to async/await in node.js
