Last active
September 1, 2022 13:47
-
-
Save TorbjornHoltmon/b62b99f631a6c81bec51df355d21ebb0 to your computer and use it in GitHub Desktop.
Awaitable timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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