If you are using async with version 3.x, we have a big change - Support async/await , with the version, with tasks which have been wrap to a Promise (when you use async/await keyword) then the callback will be disable, you need to return value in the tasks instead of call callback(null, value).
This mean, to fix your case, the code will come to:
function classify(filename) { var stack = []; var functionOne = async function(){ // remove callback param //call to an API res = await classifierOne(filename); return res; // return value } var functionTwo = async function(){ //call to an API res = await classifierTwo(filename); return res; } var functionThree = async function(){ //call to an API res = await classifierThree(filename); return res; } var functionFour = async function(){ //call to an API res = await classifierFour(filename); return res; } stack.push(functionOne); stack.push(functionTwo); stack.push(functionThree); stack.push(functionFour); async.parallel(stack, function(err, res){ console.log(res[0]); }) }
P/s: My suggestion is using Promise.all for this case. Say no to callback.
async function classify(filename) { // Make this function become a async function var stack = []; var functionOne = async function(){ // remove callback param //call to an API res = await classifierOne(filename); return res; // return value } var functionTwo = async function(){ //call to an API res = await classifierTwo(filename); return res; } var functionThree = async function(){ //call to an API res = await classifierThree(filename); return res; } var functionFour = async function(){ //call to an API res = await classifierFour(filename); return res; } stack.push(functionOne); stack.push(functionTwo); stack.push(functionThree); stack.push(functionFour); const result = await Promise.all(stack); // Wait until all "task" finish console.log(result); return result; // Return the result of all tasks } // Call classify function inner a async function const result = await classify('your_file_name'); // await keyword console.log(result);