Skip to content

Instantly share code, notes, and snippets.

@helephant
Created January 24, 2019 17:42
Show Gist options
  • Save helephant/30bc538c4cd4788ea412978e6a662233 to your computer and use it in GitHub Desktop.
Save helephant/30bc538c4cd4788ea412978e6a662233 to your computer and use it in GitHub Desktop.
Javascript snippet for getting a node process to wait for a set period of time. This is useful for debugging, probably don't want to be doing this in real code.
// sleep the function for 5 seconds
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
// Usage!
await sleep(5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment