Created
July 31, 2015 07:36
-
-
Save mosfet1kg/db9a76ae3f6a546f9152 to your computer and use it in GitHub Desktop.
Q parallel2.js
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
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