I was doing some batch IO with Promise.all, but eventually I hit a limit of open files by creating too many IO promises at once. So instead, I made an utility, that will run those promises in batches of 50 at most.
One solution is to divide the tasks in batches of fifty, and then do Promise.all on each batch. But smarter solution would be to cycle the promises as they resolve using Promise.any. Problem is, Promise.any only returns the result, and not which promise returned.
How to find out which resolved so that I can replace it in the batch with new unresolved one?