Skip to content

Instantly share code, notes, and snippets.

@TorbjornHoltmon
Last active September 1, 2022 13:47
Show Gist options
  • Save TorbjornHoltmon/b62b99f631a6c81bec51df355d21ebb0 to your computer and use it in GitHub Desktop.
Save TorbjornHoltmon/b62b99f631a6c81bec51df355d21ebb0 to your computer and use it in GitHub Desktop.
Awaitable timeout
async function voidWait(timeToDelay: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, timeToDelay));
}
async function returnWait<T>(timeToDelay: number, returnValue: T): Promise<T> {
return new Promise((resolve) => setTimeout(() => resolve(returnValue), timeToDelay));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment