Skip to content

Instantly share code, notes, and snippets.

View roychri's full-sized avatar

Christian Roy roychri

View GitHub Profile
@roychri
roychri / tools.md
Last active May 7, 2025 14:15
My Useful Tools
@jcouyang
jcouyang / README.org
Last active March 13, 2025 19:28
Promise All with Limit of Concurrent N

The Promise All Problem

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')])