Skip to content

Instantly share code, notes, and snippets.

@gabemeola
Created December 20, 2018 22:20
Show Gist options
  • Save gabemeola/24e7f8c28745a5e2d328cd575131c621 to your computer and use it in GitHub Desktop.
Save gabemeola/24e7f8c28745a5e2d328cd575131c621 to your computer and use it in GitHub Desktop.
Resolves passed function after timeout
/**
* Resolves passed function after timeout
*
* @param {number} timeout
* @param {Function} fn
* @return {Promise<any>}
*/
export default function wait(timeout, fn) {
return new Promise((resolve) => {
setTimeout(() => resolve(fn()), timeout);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment