A different semantics for WeakMap#get default value

David Bruant bruant.d at gmail.com
Tue Jan 17 00:37:46 PST 2012


Le 17/01/2012 01:46, Kris Kowal a écrit :
> On Mon, Jan 16, 2012 at 4:39 PM, Andrea Giammarchi
> <andrea.giammarchi at gmail.com>  wrote:
>> then the method should be called "getOrSetIfNotThere(obj, def)" 'cause get()
>> would mislead too much
> I’ve been calling this method "getset" for about three years, hoping
> it would catch on :P
>
> https://github.com/kriskowal/narwhal-lib/blob/f182f2f0a952d75f06b0ebe142696056d2933501/lib/narwhal/util.js
Indeed, I thought afterwards, that I could just as well create my own 
function and my own abstraction. It can be built efficiently on top of 
the current API, so everything's good.

David


More information about the es-discuss mailing list