UNPKG

promessinha

Version:

Resolves an array of promises in parallel and return an object with an array of 'successes' and an array of 'errors'.

20 lines (16 loc) 340 B
module.exports = async promises => { const result = { successes: [], errors: [] } const final = promises.map(async promise => { try { const response = await promise result.successes.push(response) } catch (error) { result.errors.push(error) } }) await Promise.all(final) return result }