in case of processing a very large array e.g. Promise.all(A_VERY_LARGE_ARRAY_OF_XHR_PROMISE)
which would probably blow you browser memory by trying to send all requests at the same time
solution is limit the concurrent of requests, and wrap promise in thunk
Promise.allConcurrent(2)([()=>fetch('BLAH1'), ()=>fetch('BLAH2'),...()=>fetch('BLAHN')])
if set concurrent to 2, it will send request BLAH1 and BLAH2 at the same time
if BLAH1 return response and resolved, will immediatly send request to BLAH3
in this way promise sending at the same time always keep the limit 2 which we’ve just configed before
A notable drawback with @webshared and @Tartasprint's implementations is that if one of the promises in the queue rejects, the other "threads" continue scheduling all of the remaining work:
Note also that the remaining tasks proceed with lower concurrency because one of the "threads" is now dead.