Skip to content

[GR-74261] Implement Await Dictionary proposal #1081

Description

@woess

TL;DR

We plan to implement the Await Dictionary of Promises proposal in GraalJS. It adds Promise.allKeyed and Promise.allSettledKeyed alternatives for Promise.all and Promise.allSettled, respectively, that allow awaiting a dictionary (rather than array) of promises.

Details

Adds:

  • Promise.allKeyed(promises)
  • Promise.allSettledKeyed(promises)
const {
  shape,
  color,
  mass,
} = await Promise.allKeyed({
  shape: getShape(),
  color: getColor(),
  mass: getMass(),
});

const results = await Promise.allSettledKeyed({
    shape: getShape(),
    color: getColor(),
    mass: getMass(),
});
if (results.shape.status === "fulfilled") {
  console.log(results.shape.value);
} else {
  console.error(results.shape.reason)
}

Metadata

Metadata

Assignees

Labels

proposalECMAScript Proposals

Projects

Status
Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions