Skip to content

Instantly share code, notes, and snippets.

@zyxd
Created May 21, 2020 18:52
Show Gist options
  • Save zyxd/f53105f64c07eec004c0898cd29aa536 to your computer and use it in GitHub Desktop.
Save zyxd/f53105f64c07eec004c0898cd29aa536 to your computer and use it in GitHub Desktop.
const wait = () => new Promise(resolve => setTimeout(resolve, 1000))
const start = async () => {
console.log('started')
await [1, 2, 3]
.map(index => async () => {
await wait()
console.log(index)
})
.reduce((p, f) => p.then(f), Promise.resolve())
console.log('done')
}
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment