tc39 / proposal-await-dictionary

A proposal to add Promise.ownProperties(), Promise.fromEntries() to ECMAScript
MIT License
86 stars 4 forks source link

`Promise.fromObject()` #15

Open Electroid opened 1 year ago

Electroid commented 1 year ago

This is the same proposal as Promise.ownProperties(), but under a different name that feels natural and approachable (imo)

const {
  shape,
  color,
  mass,
} = await Promise.fromObject({
  shape: getShape(),
  color: getColor(),
  mass: getMass(),
});
machineghost commented 1 year ago

Agreed! ownProperties is an incredibly wonky name. It does solve a very niche concern (although, with OOP declining in popularity in JS, how many devs even know about the prototype chain?), but ...

JS features shouldn't be named after wonky concerns, they should be named to be easily understood by all programmers.

ljharb commented 1 year ago

Which combinator semantics would that have - all, allSettled, race, or anySettled?

BasixKOR commented 1 year ago

ownProperties doesn't really imply the combinator semantics either though, although this may be better discussed in another issue.