tc39 / proposal-upsert

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

How `getOrInsertComputed` callback should be called? #63

Closed zloirock closed 2 weeks ago

zloirock commented 4 weeks ago

In the README polyfill example, it's just callbackFunction(). In the spec draft, it's Call(callbackfn, key) (something like callbackfn.call(key)) - that, for example, cause issues with arrow callbacks.

Should it be something like callbackFunction(key)?

ljharb commented 4 weeks ago

it should probably be more like Call(callbackfn, *undefined*, << key >>)

acutmore commented 2 weeks ago

+1 for Call(callbackfn, *undefined*, << key >>). I think it would be more natural to receive the key as an argument instead of as the receiver.