-
Notifications
You must be signed in to change notification settings - Fork 661
Open
Description
Is your feature request related to a problem? Please describe.
Add something like Promise.allKeyed/Promise.allSettledKeyed to @std/async, which is more ergonomic than all/allSettled for many use cases.
Per Await dictionary of Promises proposal § Motivation:
awaiton individual properties creates a waterfall, rather than running requests in parallelPromise.allhelps, but is based on order, rather than names, which could lead to mixups- Solutions using existing syntax can be verbose and pollute the number of variables in scope
Prior art:
Describe the solution you'd like
Something like this:
type Promises<T extends Record<string, unknown>> = {
[P in keyof T]: Promise<T[P]> | T[P]
}
type PromisesSettled<T extends Record<string, unknown>> = {
[P in keyof T]: PromiseSettledResult<T[P]>
}
export declare function promiseAllKeyed<T extends Record<string, unknown>>(
promises: Promises<T>,
): Promise<T>
export function promiseAllSettledKeyed<T extends Record<string, unknown>>(
promises: Promises<T>,
): Promise<PromisesSettled<T>>Describe alternatives you've considered
Naming — promiseAllKeyed? promiseAllProperties? promiseHash? promiseObj? etc.
Metadata
Metadata
Assignees
Labels
No labels