Await dictionary

Specification
Proposal repo

Modules

esnext.promise.all-keyed, esnext.promise.all-settled-keyed

Built-ins signatures

class Promise {
  allKeyed<T extends Record<string, unknown>>(
    obj: T
  ): Promise<{ [K in keyof T]: Awaited<T[K]> }>;

  allSettledKeyed<T extends Record<string, unknown>>(
    obj: T
  ): Promise<{ [K in keyof T]: PromiseSettledResult<Awaited<T[K]>> }>;
}

Entry points

core-js/proposals/promise-all-keyed
core-js(-pure)/full/promise/all-keyed
core-js(-pure)/full/promise/all-settled-keyed

Examples

await Promise.allKeyed({
  a: Promise.resolve(1),
  b: Promise.resolve(2),
  c: 3,
}); // => { a: 1, b: 2, c: 3 }

await Promise.allSettledKeyed({
  a: Promise.resolve(1),
  b: Promise.reject(2),
  c: 3,
}); // => { a: { status: "fulfilled", value: 1 }, b: { status: "rejected", reasone: 2 }, c: { status: "fulfilled", value: 3 } }