Skip to content

Instantly share code, notes, and snippets.

@iugo
Created August 4, 2023 03:56
Show Gist options
  • Save iugo/ed2af1a4b9d3c17961ddc6166c5b7b47 to your computer and use it in GitHub Desktop.
Save iugo/ed2af1a4b9d3c17961ddc6166c5b7b47 to your computer and use it in GitHub Desktop.
import and global await
// deno run tools/test/main.ts
import { mod1 } from './mod1.ts';
import { mod2 } from './mod2.ts';
console.log('begin main');
mod1();
mod2();
import { delay } from 'https://deno.land/std@0.167.0/async/delay.ts';
console.log('load mod1');
await delay(1000);
console.log('delay mod1 1000ms');
export function mod1() {}
import { delay } from 'https://deno.land/std@0.167.0/async/delay.ts';
console.log('load mod2');
await delay(500);
console.log('delay mod2 500ms');
await delay(1500);
console.log('delay mod2 1500ms');
export function mod2() {}
@iugo
Copy link
Author

iugo commented Aug 4, 2023

the console will print:

load mod1
load mod2
delay mod2 500ms
delay mod1 1000ms
delay mod2 1500ms
begin main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment