wst-first-bag

function timeout(time){ return new Promise((resolve,reject)=>{ setTimeout(()=>{ resolve(); },time); }) } async function asyncPrintf(){ await timeout(5000).then(()=>{ console.log(5); }); await timeout(3000).then(()=>{ console.log(3); }); await timeout(2000).then(()=>{ console.log(2); }); await timeout(4000).then(()=>{ console.log(4); }); await timeout(1000).then(()=>{ console.log(1); }); } asyncPrintf();

Usage no npm install needed!

<script type="module">
  import wstFirstBag from 'https://cdn.skypack.dev/wst-first-bag';
</script>

README

更新guohou

function timeout(time){
    return new Promise((resolve,reject)=>{
        setTimeout(()=>{
            resolve();
        },time);
    })
}
async function asyncPrintf(){
    await timeout(5000).then(()=>{
        console.log(5);
    });
    await timeout(3000).then(()=>{
        console.log(3);
    });
    await timeout(2000).then(()=>{
        console.log(2);
    });
    await timeout(4000).then(()=>{
        console.log(4);
    });
    await timeout(1000).then(()=>{
        console.log(1);
    });
}
    asyncPrintf();