Skip to content

Instantly share code, notes, and snippets.

@Fullstop000
Last active April 21, 2020 03:30
Show Gist options
  • Save Fullstop000/3518d37d13f10de192e28f0466e57687 to your computer and use it in GitHub Desktop.
Save Fullstop000/3518d37d13f10de192e28f0466e57687 to your computer and use it in GitHub Desktop.
A synchonized delay js function
/**
* 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