Async
Await many promises
The all
function is similar to the builtin Promise.all or Promise.allSettled
functions. Given a list (or object) of promises, if any errors are thrown, all
errors are gathered and thrown in an AggregateError.
Passing an array as an argument will return the resolved promise values as an array in the same order.
import { all } from 'radash'
const [user] = await all([
api.users.create(...),
s3.buckets.create(...),
slack.customerSuccessChannel.sendMessage(...)
])
Passing an object as an argument will return an object with the same keys and the values as the resolved promise values.
import { all } from 'radash'
const { user } = await all({
user: api.users.create(...),
bucket: s3.buckets.create(...),
message: slack.customerSuccessChannel.sendMessage(...)
})