Skip to content

Instantly share code, notes, and snippets.

@samzhao
Created June 30, 2018 03:50
Show Gist options
  • Save samzhao/0ffb6e94ac7bceab5404babc6ca45f04 to your computer and use it in GitHub Desktop.
Save samzhao/0ffb6e94ac7bceab5404babc6ca45f04 to your computer and use it in GitHub Desktop.
Making async/await delay helper work in a loop
const delay = time =>
new Promise(resolve => setTimeout(resolve, time));
const list = new Array(10).fill();
for (let index of list.keys()) {
await delay(1000);
console.log(index);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment