Processing tasks as they are completed
I was reading some Python code and really like the signature of asyncio.as_completed()
. It returns an iterable of tasks that you can await. What’s really nice about this is that it’s very intuitive. The first task that you await is the first task that completes.
I’ve decided to implement a version of it in typescript.
Setup
We want a way to generate a list of async tasks with random delays. The following should do that