Module for executing promises in sequence.
var promiseq = require('promisequence');
function one(result) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(result);
},1000);
});
}
function two(data, prevValue) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve('2');
},1000);
});
}
var someData = {
value: 200
};
promiseq([Promise.resolve('0'), one(1), two], someData).then(function(values) {
console.log(values.results[0])
console.log(values.results[1])
console.log(values.results[2])
console.log(values.data.value)
});