Allow a custom ts specification of waitUntil base.js
This commit is contained in:
parent
a3dfbbdde4
commit
9fbfd38311
|
@ -236,12 +236,13 @@ function getNormalizedURI() { return window.location.pathname.replace(/\/+?$/, '
|
||||||
function capitalize(s) { return s.charAt(0).toUpperCase() + s.substr(1) }
|
function capitalize(s) { return s.charAt(0).toUpperCase() + s.substr(1) }
|
||||||
function randomNum(min, max) { return Math.floor(Math.random() * (max - min) + min) }
|
function randomNum(min, max) { return Math.floor(Math.random() * (max - min) + min) }
|
||||||
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)) }
|
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)) }
|
||||||
async function waitUntil(cback, secs) {
|
async function waitUntil(cback, ticks, ts) {
|
||||||
|
ts = ts || 1000;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (i < secs) {
|
while (i < ticks) {
|
||||||
if (cback())
|
if (cback())
|
||||||
return;
|
return;
|
||||||
await sleep(1000);
|
await sleep(ts);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue