Additional cascading Map/Set/WeakMap methods?

Brandon Benvie brandon at brandonbenvie.com
Sun Jan 13 17:14:40 PST 2013


delete is supposed to return whether the item was in the collection to
delete or not, which otherwise would require using has to check for before
deleting. I don't know how useful the functionality is, but wanted to note
it since it'd be lost with this change. Chaining `clear` is an easy
definitely though.


On Sun, Jan 13, 2013 at 7:58 PM, Tab Atkins Jr. <jackalmage at gmail.com>wrote:

> On Sun, Jan 13, 2013 at 4:44 PM, Allen Wirfs-Brock
> <allen at wirfs-brock.com> wrote:
> > At the last TC39 meeting, it was agreed tothat the set/add methods would
> return the collection that to which something is being added.
> >
> > This supports code patterns like:
> >
> > someMap.set(key1,value1).set(key2,value3);
> >
> > In making this change to the spec. I noticed several other methods that
> could reasonably be used in this same pattern. For example:
> >
> > someMap.clear().set(aKey, aValue);
> >
> > someSet.delete(oldMember).add(newMember);
> >
> > Are there any objections to making the clear and delete methods of
> Map/WeakMap/Set also return the collection, just like set/add?
>
> None from me.  If I was a TC39 member, I'd object to *not* adding them.
>  ^_^
>
> ~TJ
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130113/3cf53199/attachment.html>


More information about the es-discuss mailing list