Skip to content

Instantly share code, notes, and snippets.

@viebig
Created March 28, 2016 18:26
Show Gist options
  • Save viebig/9f72874d87162fd7eaa5 to your computer and use it in GitHub Desktop.
Save viebig/9f72874d87162fd7eaa5 to your computer and use it in GitHub Desktop.
Bluebird Promise.all example
var Promise = require('bluebird');
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
console.log(milliseconds)
return milliseconds
break;
}
}
}
Promise.all([sleep(1000), sleep(500)]).then(function(res){
console.log(res)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment