mirror of
https://github.com/discordeno/discordeno.git
synced 2026-05-28 14:30:11 +00:00
* fix: get tests runnable * fix: tests are now passing * fix: 32 passing tests * fix: deno fmt u dumb dumb work automatically for once in your life * fix: 54 tests passing now * fix: 94 passing, itoh was wrong he guess wrong hehe * fix: remove debug logs * fix: remove broken webhook test for now Co-authored-by: ITOH <to@itoh.at>
20 lines
468 B
TypeScript
20 lines
468 B
TypeScript
export function delayUntil(
|
|
maxMs: number,
|
|
isReady: () => boolean | undefined | Promise<boolean | undefined>,
|
|
timeoutTime = 100,
|
|
): Promise<void> {
|
|
const maxTime = Date.now() + maxMs;
|
|
|
|
async function hackyFix(resolve: () => void) {
|
|
if ((await isReady()) || Date.now() >= maxTime) {
|
|
resolve();
|
|
} else {
|
|
setTimeout(() => {
|
|
hackyFix(resolve);
|
|
}, timeoutTime);
|
|
}
|
|
}
|
|
|
|
return new Promise((resolve) => hackyFix(resolve));
|
|
}
|