Skip to content

Instantly share code, notes, and snippets.

@anthonyserious
Last active August 29, 2015 14:12
Show Gist options
  • Save anthonyserious/fd8b7f222eb3d385608c to your computer and use it in GitHub Desktop.
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
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