node.js async series function's arguments

前端 未结 4 2004
夕颜
夕颜 2021-02-20 06:49

I need to do the code like following:

function taskFirst(k, v) {
    console.log(k, v);
}

function taskSecond(k, v) {
    console.log(k, v);
}

function run() {         


        
4条回答
  •  悲&欢浪女
    2021-02-20 07:18

    Better way.

    const a1 = (a, callback) => {
        console.log(a, 'a1')
        callback()
    }
    const a2 = (a, callback) => {
        console.log(a, 'a2')
        callback()
    }
    
    const run = () => {
        async.series([
            a1.bind(null, 'asd'),
            a2.bind(null, 'asd2')
        ], () => {
            console.log('finish')
        })
    }
    run()
    

提交回复
热议问题