You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
425 B
22 lines
425 B
|
2 years ago
|
export default function settle (promises) {
|
||
|
|
const resolutions = []
|
||
|
|
const rejections = []
|
||
|
|
function resolved (value) {
|
||
|
|
resolutions.push(value)
|
||
|
|
}
|
||
|
|
function rejected (error) {
|
||
|
|
rejections.push(error)
|
||
|
|
}
|
||
|
|
|
||
|
|
const wait = Promise.all(
|
||
|
|
promises.map((promise) => promise.then(resolved, rejected)),
|
||
|
|
)
|
||
|
|
|
||
|
|
return wait.then(() => {
|
||
|
|
return {
|
||
|
|
successful: resolutions,
|
||
|
|
failed: rejections,
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|