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

since `insertFn` is optional, it should be noted as such #7

Closed ljharb closed 5 years ago

ljharb commented 5 years ago

The signature for this method should be (key, updateFn[, insertFn]) since you're able to omit it.

bmeck commented 5 years ago

insertFn isn't optional if you omit updateFn though. It's a bit odd. Since you need at least 1 fn insertFN is only optional in light of the value of updateFn and cannot always be omitted.

ljharb commented 5 years ago

right, but omitting updateFn requires an explicit undefined - so the .length of the function is 2, because 2 arguments are required at minimum. That there's validation performed on the 2nd, and that its value may force a 3rd to be required, is separate.