1
0
mirror of https://git.topisto.net/tibo/template.git synced 2026-03-31 21:39:10 +00:00
Files
template/frontend/src/scripts/tools/delai.js
2024-09-13 17:26:06 +02:00

28 lines
476 B
JavaScript

/*
* 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);
}