mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 16:30:08 +00:00
* fix: guild create tests * fix(test): use setTimeout instead of while loop and fix some tests * fix(test): fix some test and fix maxMs Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
18 lines
440 B
TypeScript
18 lines
440 B
TypeScript
export async function delayUntil(maxMs: number, isReady: () => boolean, timeoutTime= 100): Promise<void> {
|
|
const maxTime = Date.now() + maxMs;
|
|
|
|
function hackyFix(resolve: () => void) {
|
|
if (isReady() || Date.now() >= maxTime) {
|
|
resolve();
|
|
}
|
|
else {
|
|
setTimeout(async () => {
|
|
await hackyFix(resolve);
|
|
resolve();
|
|
}, timeoutTime);
|
|
}
|
|
}
|
|
|
|
return new Promise(resolve => hackyFix(resolve));
|
|
}
|