Created
July 19, 2018 17:46
-
-
Save pulkitsinghal/8a13f444b1be7e7e92cdd02e52fba6c8 to your computer and use it in GitHub Desktop.
How does promise.all() implementation behave in bluebird?
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'); | |
var a=0, b=0, c=0, d=0, e=0; | |
var tests = [ | |
Promise.delay(5000).then(function(){a++; return Promise.resolve("hell5");}), | |
Promise.delay(1000).then(function(){b++; return Promise.resolve("hell4");}), | |
Promise.delay(3000).then(function(){c++; return Promise.resolve("hell3");}), | |
Promise.delay(2000).then(function(){d++; return Promise.reject("heaven2");}), | |
Promise.delay(1000).then(function(){e++; return Promise.resolve("hell1");}) | |
]; | |
return Promise.all(tests) | |
.then(function(){ | |
console.log('then', arguments); | |
return Promise.resolve(); | |
}) | |
.catch(function(){ | |
console.log('catch', arguments); | |
console.log('a', a); | |
console.log('b', b); | |
console.log('c', c); | |
console.log('d', d); | |
console.log('e', e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment