Created
March 28, 2016 18:26
-
-
Save viebig/9f72874d87162fd7eaa5 to your computer and use it in GitHub Desktop.
Bluebird Promise.all example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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