Files
reacord/packages/website/app/modules/helpers/promise-all-object.ts
2022-01-14 15:58:06 -06:00

14 lines
304 B
TypeScript

export async function promiseAllObject<Input extends object>(
input: Input,
): Promise<{
[K in keyof Input]: Awaited<Input[K]>
}> {
const result: any = {}
await Promise.all(
Object.entries(input).map(async ([key, promise]) => {
result[key] = await promise
}),
)
return result
}