this shell will wait and return every result and / or deviation
the returned array will be objects
{ // this one resolved ok: true, value: 'original resolved value' }, { // this one rejected ok: false, error: 'original rejected value' }, { // this one resolved ok: true, value: 'original resolved value' }, // etc etc
One caveat: this will cause ALL promises to allow or reject, rather than reject, as soon as the first rejection occurs
let allresults = function(arr) { return Promise.all(arr.map(item => (typeof item.then == 'function' ? item.then : Promsie.resolve(item))(value => ({value, ok:true}), error => ({error, ok:false})))); } allresults(arrayOfPromises) .then(results => { results.forEach(result => { if(result.ok) {
source share