function step1(query) { return new Promise((success) => { let waiting=2000; setTimeout(() => { success('wait-time:'+waiting+' step:'+query); }, waiting); }); } function step2(query) { return new Promise((success) => { let waiting=1000; setTimeout(() => { success('wait-time:'+waiting+' step:'+query); }, waiting); }); } function step3(query) { return new Promise((success) => { let waiting=500; setTimeout(() => { success('wait-time:'+waiting+' step:'+query); }, waiting); }); }
const task = async()=>{ await step1('step1').then((success) => { console.log(success); });
await step2('step2').then((success) => { console.log(success); });
await step3('step3').then(success => { console.log(success); }); }; task();
|