Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sashaegorov
Created December 25, 2017 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sashaegorov/dd195ba4c213c83fd65e4039bfc92f90 to your computer and use it in GitHub Desktop.
Save sashaegorov/dd195ba4c213c83fd65e4039bfc92f90 to your computer and use it in GitHub Desktop.
Await and Sleep
function sleep (time, arg) {
console.log(`Sleep started for ${arg}...`);
return new Promise((resolve) => {
setTimeout(() => {
resolve(arg);
}, time);
});
}
await sleep(1000, this.report.pagination.pageNumber)
.then((a) => {
console.log(`Sleep stopped ${a}...`);
console.log(`Sleep stopped ${this}!`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment