Last active
July 8, 2022 12:08
-
-
Save NuroDev/e5db97f3fd05788156e1407e21567fc3 to your computer and use it in GitHub Desktop.
π Async Timeout β Asynchronous wrapper for the standard JavaScript setTimeout function
This file contains hidden or 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
const setTimeoutAsync = < | |
TCallback extends Function = () => void | Promise<void> | |
>( | |
cb: TCallback, | |
delay: number | |
) => | |
new Promise((resolve) => | |
setTimeout(() => { | |
resolve(cb()); | |
}, delay) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment