News for hackers. Stuff that matters.
Re:Internals of Async / Await in JavaScript by mistercow on Saturday September 02, 2023 @11:42AM (#37362514)
Generators are a super clean way to do stream processing (in fact, in modern node, streams are async iterators, and can be used with “for await”). The really nice thing is that you can chain together a whole pipeline of generators to do transformations on a stream which are much more complex than map.

For example, do you have a stream of chunks, and want to turn it into a stream of lines? The implementation of this with generators is super clean and readable, because it’s like you’re just iterating over a list.

There are no comments on this comment yet.