我在具有相同回调函数的两个函数中使用async.parallel。在第二个函数(two())中添加了第三个函数作为加法函数

function one(){
var testuser = 1;
 async.parallel([onefunction, secondfunction], function(err, result){...})
}

function two(){
var testuser = 2;
async.parallel([onefunction, secondfunction, thirdfunction], function(err, result){...})
}

function onefunction(callback){....code with testuser......}
function twofunction(callback){....code with testuser......}
function thirdfunction(callback){....code with testuser......}

问:如何访问onefunctionsecondfunctionthirdfunction中的testuser值。

现在我得到 undefined err 。我还尝试了正常参数传递逻辑onefunction(testuser),但是它不起作用。

我想在多种情况下使用onefunctiontwofunction ...我该怎么做?

最佳答案

正如@Felix所建议的那样,

function one(){
var testuser = 1;
 async.parallel([onefunction, secondfunction], function(err, result){...})
}

    function two(){
    var testuser = 2;
    async.parallel([
       callback => onefunction(testuser, callback),
       callback => twofunction(testuser, callback),
       callback => thirdfunction(testuser, callback)], function(err, result){...})
    }

    function onefunction(callback){....code with testuser......}
    function twofunction(callback){....code with testuser......}
    function thirdfunction(callback){....code with testuser......}

10-04 19:19