tc39 / proposal-upsert

ECMAScript Proposal, specs, and reference implementation for Map.prototype.upsert
https://tc39.es/proposal-upsert/
MIT License
204 stars 14 forks source link

document what qualifies a parameter as too heavy? #30

Closed bmeck closed 1 month ago

bmeck commented 4 years ago

We have various parties that disagree on weight / ergonomics of using an object for a parameter vs 2 function parameters:

CC: @waldemarhorwat , @codehag , @ljharb , @jorendorff , @erights

It would be good to get some matrix of design directions we can take without mandating a specific design. We have various things mentioned.

It would be good to clear up each of these claims and prioritize them.

stiff commented 3 years ago

I'm for 2 parameters here. Second function can be defaulted to identity allowing to map.emplace(key, Ramda.always(42)) for just inserts. To reuse arguments you always can do it like

insertupdate = [Ramda.always(42), Ramda.add(42)];
map.emplace(key, ...insertupdate);

Of course not as eloquent as emplace(key, { insert() { return ... }, update() { return } }) but also way more compact and with less curly brackets.

papb commented 2 years ago

@stiff What if you only want an update action?

stiff commented 2 years ago

Good point, with { update: () => ... } it's much simpler. Still possible with something like map.emplace(key, null, x => x + 1)

dminor commented 1 month ago

The new design is focusing on just the insert use case, so this discussion is no longer relevant.