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

Should `key` argument of `WeakMap` methods be validated before attempt to set the value? #64

Closed zloirock closed 3 weeks ago

zloirock commented 1 month ago

It's observable with something like

new WeakMap().getOrInsertComputed(1, () => console.log('called'))
ljharb commented 1 month ago

Yes, all arguments should always be validated, in order, before attempting to do anything else.

zloirock commented 3 weeks ago

Fixed in #61.