CoddityTeam / movaicode

Concours mensuel du Pire Développeur de France
122 stars 10 forks source link

Linear Wait13s #250

Open Redriel57 opened 2 years ago

Redriel57 commented 2 years ago

Reste plus qu'à attendre les 13 secondes

async function wait13s(){
  dt=process.hrtime()
  dt=dt[0]*1000+dt[1]/1000000
  chronometre=[1]
  copie_de_chronometre=[]
  while(process.hrtime()[0]*1000+process.hrtime()[1]/1000000-dt+copie_de_chronometre<13000){
    copie_de_chronometre=[]
    for(j=chronometre.length;j!=chronometre[0]-1;j=j-1) copie_de_chronometre.push(chronometre[chronometre.length-j])
    copie_de_chronometre=copie_de_chronometre[copie_de_chronometre.length-1]+1
    chronometre.push(copie_de_chronometre)
    await new Promise(resolve=>setTimeout(resolve,chronometre[chronometre.length-1]))
  }
  await new Promise(resolve=>setTimeout(resolve,13000-process.hrtime()[0]*1000+process.hrtime()[1]/1000000-dt))
}