Skip to content

Instantly share code, notes, and snippets.

@mosfet1kg
Created July 31, 2015 07:36
Show Gist options
  • Save mosfet1kg/db9a76ae3f6a546f9152 to your computer and use it in GitHub Desktop.
Save mosfet1kg/db9a76ae3f6a546f9152 to your computer and use it in GitHub Desktop.
Q parallel2.js
var Q = require('q');
var func = [];
func.push(function (){
var d = Q.defer();
d.resolve('a');
console.log('a');
return d.promise;
});
func.push(function () {
console.log(arguments);
var d = Q.defer();
d.resolve('b');
console.log('b');
return d.promise;
});
var result = Q();
func.forEach(function (f) {
result = result.then(f)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment