Created
April 17, 2019 19:14
-
-
Save mhkeller/fe71b41fbfc5c03e4776a71315a492b7 to your computer and use it in GitHub Desktop.
Throttle requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sleep = ms => new Promise(f => setTimeout(f, ms)); | |
async function do_things() { | |
for (const thing of things) { | |
await Promise.all([ | |
doThing(thing), | |
sleep(200) | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment