Set some, every, reduce, filter, map methods

Rick Waldron waldron.rick at gmail.com
Sat Mar 30 10:58:41 PDT 2013


On Saturday, March 30, 2013, Erik Arvidsson wrote:

> I said this in the other thread but I don't mind repeating myself. A
> better way forward is to provide these for iterators.
>
> mySet.values().some(func)
> mySet.values().every(func)
> mySet.values().reduce(func)
> new Set(mySet.values().filter(func))
> new Set(mySet.values().map(func))


My intention is not to refute the above, but these methods can be used by
spreading the iterable set into an array:

[...mySet].some(func)

Of course this has allocation costs...

Rick




>
> I'm not opposed to adding these to Set and Map but I think it is more
> important to define these using iterators first since it scales better
> to new collection types.
>
> On Mar 30, 2013 8:06 AM, "Herby Vojčík" <herby at mailbox.sk <javascript:;>>
> wrote:
> >
> > Definitely, +1.
> >
> > Also, add reduceRight as well, even if it would only do the same as
> reduce.
> >
> > Peter Michaux wrote:
> >>
> >> In another thread, I'm told there is currently no plans to add the
> >> following to Set.prototype.
> >>
> >> some
> >> every
> >> reduce
> >> filter
> >> map
> >>
> >> These seem like very natural additions and the type of operations that
> >> one would want to do on sets.
> >>
> >> Peter
> >> _______________________________________________
> >> es-discuss mailing list
> >> es-discuss at mozilla.org <javascript:;>
> >> https://mail.mozilla.org/listinfo/es-discuss
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org <javascript:;>
> > https://mail.mozilla.org/listinfo/es-discuss
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org <javascript:;>
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130330/c63e9c2e/attachment.html>


More information about the es-discuss mailing list