Last active
April 21, 2020 03:30
-
-
Save Fullstop000/3518d37d13f10de192e28f0466e57687 to your computer and use it in GitHub Desktop.
A synchonized delay js function
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
/** | |
* This delay function returns a Promise which will fullfill when the timer goes off | |
*/ | |
export default function delay(fn, duration) { | |
return new Promise(resolve => setTimeout(() => { fn(); resolve()}), duration) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment