mirror of
https://git.topisto.net/tibo/template.git
synced 2026-04-01 01:59:11 +00:00
initialisation with SMETI code
This commit is contained in:
27
frontend/src/scripts/tools/delai.js
Normal file
27
frontend/src/scripts/tools/delai.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user