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
@atolkachiov thanks for this brilliant JS implementation.
Let's say I'm storing the HTTP responses of each makeHTTPRequest in a global array. I'd like to retry those that fail (i.e. HTTP response <> 200). How should I chain another pAll call, so it runs right after the first completed? I tried this but didn't work.