4 ms·
Yep, JS is still single threaded, and all that. I agree async iteration is pretty good - the `Chan` class implements both `Iterable` and `AsyncIterable`. For
by joeycumines 3y ago
Yep, JS is still single threaded, and all that.
I agree async iteration is pretty good - the `Chan` class implements both `Iterable` and `AsyncIterable`.
For quite a few scenarios, async generators are a better choice. They do have limitations, however. For example, you _can_ implement fan-in, but there's no easy mechanism to fan-in in a blocking manner, from sources that aren't known ahead of time. It's also hard to implement a "fair" mechanism, that doesn't bias certain inputs (like you might desire if multiplexing logs, for example).
- felipellrocha 3y agoCouldn’t you spin N workers and assign work to them?
- joeycumines 3y agoFan-in is the other way, but yeah you can do batches of concurrent operations in JS fairly easily. I still like "pipelining" over that, but that can also be implemented with just an iterator, pretty trivially.
- kreetx 3y agoThe value proposition of the library became much clearer, thanks for explaining!