Skip to content

Instantly share code, notes, and snippets.

@mhkeller
Created April 17, 2019 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhkeller/fe71b41fbfc5c03e4776a71315a492b7 to your computer and use it in GitHub Desktop.
Save mhkeller/fe71b41fbfc5c03e4776a71315a492b7 to your computer and use it in GitHub Desktop.
Throttle requests
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