Last active
August 29, 2015 14:12
-
-
Save anthonyserious/fd8b7f222eb3d385608c to your computer and use it in GitHub Desktop.
Q promise array reduce example based on http://stackoverflow.com/a/17764496/3753772
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
var Q = require("q"); | |
var arr = [1,2,3,4]; | |
arr.reduce(function(prev, item) { | |
return prev.then(function(p) { | |
console.log(item); | |
return Q.delay(0); | |
}); | |
}, Q.resolve(1)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment