I want to run an async function N times but for performance reasons have M calls running simultaneously. So at the start I would fire off two function calls and then when the first of those finishes I should start the 3rd and, when the next finishes start the 4th. When the last has started I then need to wait for the final two to finish.
I should never have more than 2 running at any time.
I've been looking at how to do this with Promise.any()
but not quite been able to work it out.