The Code
I tried this package https://www.npmjs.com/package/async to implement series & parallel processing.
For small cases it works, well, however when I try to run this, I get an unexpected behavior:
async.series([
function(callback){
console.log('one');
callback();
},
function(callback){
console.log('two');
async.parallel([
function(callback){
console.log('two-one');
callback();
},
function(callback){
async.series([
function (callback){
console.log('two-two-one');
callback();
},
function (callback){
console.log('two-two-two');
callback();
}
]);
}
], callback);
},
function(callback){
console.log('three');
callback();
}
]);
The Expected Result
The code should print one, two, two-one, and three in series. However, after print two-one, I want to print two-two-one and two-two-two in parallel.
The expected result is either:
one
two
two-one
two-two-one
two-two-two
three
or
one
two
two-one
two-two-two
two-two-one
three
The Real Result
Unfortunately, three is never printed.
one
two
two-one
two-two-one
two-two-two
The Question
Is there something wrong with my code/understanding?
Thanks.