Skip to content

Instantly share code, notes, and snippets.

@pulkitsinghal
Last active July 19, 2018 17:48
Show Gist options
  • Save pulkitsinghal/16fa0444f86c7cfdd1e9ae67c8d614d0 to your computer and use it in GitHub Desktop.
Save pulkitsinghal/16fa0444f86c7cfdd1e9ae67c8d614d0 to your computer and use it in GitHub Desktop.
How does promise.map() implementation behave in bluebird?
var Promise = require('bluebird');
var tests = [
"hell",
"hell",
"hell",
"heaven",
"hell"
];
var networkCall = function(test) {
if (test == "heaven") {
console.log('failure');
return Promise.reject();
} else {
console.log('great success');
return Promise.resolve();
}
};
return Promise.map(
tests,
function(test) {
return networkCall(test)
.catch(function(){
console.log('forgiveness is key if you wish to continue with the rest');
return Promise.resolve();
})
}
)
.then(function(){
console.log('then2', arguments);
return Promise.resolve();
})
.catch(function(){
console.log('catch2', arguments);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment