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