support sync conditions

This commit is contained in:
Amin Yahyaabadi 2020-09-16 17:36:54 -05:00 committed by Sadick
parent 79446ad2ef
commit 12ddf94d25

View File

@ -7,7 +7,12 @@ async function conditionPromise(
while (true) {
await timeoutPromise(100);
if (await condition()) {
// if condition is sync
if (condition.constructor.name !== 'AsyncFunction' && condition()) {
return;
}
// if condition is async
else if (await condition()) {
return;
}