Le 01/01/2014 00:34, Brandon Benvie a écrit :
How about Maps?
Sets and arrays are very much alike in that they are collections of items. Maps are more like objects. I'd expect maps to have methods like the one we apply on object (Object.keys, etc.), but I think everything is covered.
I guess a default toJSON could help Maps too.

And since their order is deterministic, how about the rest of the array extras?
I don't have a strong opinion either way. I've noticed I wanted the one I listed, but felt like being conservative for a first shot of suggestions.

I feel there might be room for some static methods too like Set.union and Set.intersection. These are annoying with arrays (while keeping uniqueness of elements)

David



On Dec 31, 2013, at 11:36 AM, David Bruant <bruan...@gmail.com> wrote:

Hi,

I've been playing with Sets recently and believe that the following additions 
would make them more useful by default:
* Set.prototype.map
* Set.prototype.filter
* Set.prototype.toJSON = function(){
    return [...this];
};

The 2 first are to easily create sets from existing sets very much like what we 
already have with arrays. I haven't had a use for a .reduce yet, but maybe that 
would make sense too?
The toJSON is just to provide a good default. Obviously anyone disatisfied with 
it can shadow it on specific instances. But this serialization makes more sense 
by default than the one you get now (own properties of the set object... which 
have none in common usages?)

Hopefully both IE11 and Firefox having shipped Sets without this toJSON 
behavior won't prevent this change?

David
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to