mirror of
https://github.com/denoland/deno.git
synced 2024-11-01 09:24:20 -04:00
23 lines
497 B
TypeScript
23 lines
497 B
TypeScript
|
let intervalHandle: number;
|
||
|
let firstIntervalPromise: Promise<void>;
|
||
|
|
||
|
addEventListener("load", () => {
|
||
|
firstIntervalPromise = new Promise((resolve) => {
|
||
|
let firstIntervalCalled = false;
|
||
|
intervalHandle = setInterval(() => {
|
||
|
if (!firstIntervalCalled) {
|
||
|
resolve();
|
||
|
firstIntervalCalled = true;
|
||
|
}
|
||
|
}, 5);
|
||
|
});
|
||
|
});
|
||
|
|
||
|
addEventListener("unload", () => {
|
||
|
clearInterval(intervalHandle);
|
||
|
});
|
||
|
|
||
|
Deno.test("wait", async function () {
|
||
|
await firstIntervalPromise;
|
||
|
});
|