|
|
/*
|
|
|
* Fonction pour introduire une attente
|
|
|
* usage : await delai(1000);
|
|
|
*/
|
|
|
function delai(milliseconds){
|
|
|
return new Promise(resolve => {
|
|
|
setTimeout(resolve, milliseconds);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
var waitLoop = (ms) => {
|
|
|
const start = Date.now();
|
|
|
let now = start;
|
|
|
while (now - start < ms) {
|
|
|
now = Date.now();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
async function attendre1(milliseconds)
|
|
|
{
|
|
|
await delai(milliseconds);
|
|
|
}
|
|
|
|
|
|
function attendre(milliseconds)
|
|
|
{
|
|
|
waitLoop(milliseconds);
|
|
|
}
|