mirror of
https://github.com/denoland/deno.git
synced 2024-11-15 16:43:44 -05:00
24 lines
311 B
JavaScript
24 lines
311 B
JavaScript
|
export const foo = "foo";
|
||
|
|
||
|
export function delay(ms) {
|
||
|
return new Promise((res) =>
|
||
|
setTimeout(() => {
|
||
|
res();
|
||
|
}, ms)
|
||
|
);
|
||
|
}
|
||
|
|
||
|
let i = 0;
|
||
|
|
||
|
async function timeoutLoop() {
|
||
|
await delay(1000);
|
||
|
console.log("timeout loop", i);
|
||
|
i++;
|
||
|
if (i > 5) {
|
||
|
return;
|
||
|
}
|
||
|
timeoutLoop();
|
||
|
}
|
||
|
|
||
|
timeoutLoop();
|