Skip to content

Instantly share code, notes, and snippets.

@luchosrock
Created April 20, 2018 15:36
Show Gist options
  • Save luchosrock/08cd8fd68a131a8ac4be64d903416203 to your computer and use it in GitHub Desktop.
Save luchosrock/08cd8fd68a131a8ac4be64d903416203 to your computer and use it in GitHub Desktop.
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
var results = Promise.all([1,2,3].map(async (x) => { sleep(5000); await console.log(x); }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment