SOURCE

async function scan(i){
    return new Promise((resolve, reject) => {
        setTimeout(()=>{            
            console.log('job #'+i+' is working!')
            resolve('result #'+i)
        },1500*i)
    })

}

async function processCtrl(){
    console.log('Starting jobs...')
    let job1 = await scan(1)
    let job2 = await scan(2)
    let job3 = await scan(3)
    // job1.resolve()
    // job1.then(()=>{console.log('job1 done!')})
    // job1.then(()=>{console.log('job2 done!')})
    //await Promise.all([job1,job2])
    console.log('All jobs done!')
    

    return
}

async function mapAndScan(max){
    let group = [1,2,3,4,5,6]

    group.map(async x=>{
        console.log('starting #'+x)
        let result =await scan(x)
        console.log(result)
    })
}

//res = processCtrl()
mapAndScan(6)
console 命令行工具 X clear

                    
>
console