I need to call 3 functions, which must work synchronously. When all functions will finish execution, then I need to execute console.log for example.
Schematic example:
function one() {
console.log('one');
}
function two() {
console.log('two');
}
function three() {
console.log('three');
}
one();
two();
three();
if ( ... function one, two and three were completed ... ) {
console.log('Success!');
}
The main condition is that the functions performed synchronously. Maybe it is possible to do with async library?
Yes, with parallel :
async.parallel([one,two,three], function (err, results) {
console.log('Success!');
});
Note that the one,two, three functions must all accept a callback argument, into which they will send their result or failure when completed.