a function that returns true when the test condition is met
the function called after a timeout
miliseconds to wait for the test function to return true before timing out
let test = 1;
const trueFunc = () => {test == 1}
const falseFunc = () => {test == 2}
const timeoutFunc = () => {console.warn('timeout!')}
waitForConditionAsync(trueFunc, timeoutFunc, 3000); // returns right away
waitForConditionAsync(falseFunc, timeoutFunc, 3000); // returns in 3s and console.warn('timeout!')
Returns a Promise that completes when the test function returns true, or after the timeout has elapsed