11cb0ef41Sopenharmony_ciconst allSettled = 21cb0ef41Sopenharmony_ci Promise.allSettled ? promises => Promise.allSettled(promises) 31cb0ef41Sopenharmony_ci : promises => { 41cb0ef41Sopenharmony_ci const reflections = [] 51cb0ef41Sopenharmony_ci for (let i = 0; i < promises.length; i++) { 61cb0ef41Sopenharmony_ci reflections[i] = Promise.resolve(promises[i]).then(value => ({ 71cb0ef41Sopenharmony_ci status: 'fulfilled', 81cb0ef41Sopenharmony_ci value, 91cb0ef41Sopenharmony_ci }), reason => ({ 101cb0ef41Sopenharmony_ci status: 'rejected', 111cb0ef41Sopenharmony_ci reason, 121cb0ef41Sopenharmony_ci })) 131cb0ef41Sopenharmony_ci } 141cb0ef41Sopenharmony_ci return Promise.all(reflections) 151cb0ef41Sopenharmony_ci } 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_cimodule.exports = promises => allSettled(promises).then(results => { 181cb0ef41Sopenharmony_ci let er = null 191cb0ef41Sopenharmony_ci const ret = new Array(results.length) 201cb0ef41Sopenharmony_ci results.forEach((result, i) => { 211cb0ef41Sopenharmony_ci if (result.status === 'rejected') 221cb0ef41Sopenharmony_ci throw result.reason 231cb0ef41Sopenharmony_ci else 241cb0ef41Sopenharmony_ci ret[i] = result.value 251cb0ef41Sopenharmony_ci }) 261cb0ef41Sopenharmony_ci return ret 271cb0ef41Sopenharmony_ci}) 28