Created
May 21, 2020 18:52
-
-
Save zyxd/f53105f64c07eec004c0898cd29aa536 to your computer and use it in GitHub Desktop.
This file contains 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 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