Skip to content

Instantly share code, notes, and snippets.

@saylestyler
Created June 10, 2018 09:32
Show Gist options
  • Save saylestyler/41c9ce3cc7f2da383695fe20cfc8c2b6 to your computer and use it in GitHub Desktop.
Save saylestyler/41c9ce3cc7f2da383695fe20cfc8c2b6 to your computer and use it in GitHub Desktop.
let p = (v) => {
return new Promise((resolve, reject) => {
setTimeout(resolve, 1000)
}).then(() => v)
}
[1, 2, 3, 4, 5].reduce((seq, curr) => {
return seq.then(() => p(curr)).then(console.log)
}, Promise.resolve())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment