Skip to content

Instantly share code, notes, and snippets.

@chemdemo
Created January 13, 2016 11:42
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 chemdemo/d067ac2b6168682a7928 to your computer and use it in GitHub Desktop.
Save chemdemo/d067ac2b6168682a7928 to your computer and use it in GitHub Desktop.
Promises series queue
'use strict';
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