Skip to content

Instantly share code, notes, and snippets.

@snsinfu
Created March 10, 2021 05:26
Show Gist options
  • Save snsinfu/38bd2081b331ada7733e2b2dda7454c0 to your computer and use it in GitHub Desktop.
Save snsinfu/38bd2081b331ada7733e2b2dda7454c0 to your computer and use it in GitHub Desktop.
Typescript async sleep
function asleep(delay: number): Promise<void> {
return new Promise<void>((resolve, reject) => setTimeout(resolve, delay));
}
console.log(Date.now());
await asleep(100);
console.log(Date.now());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment