Dmitry Soshnikov wrote:
From: es-discuss [mailto:[email protected]] On Behalf Of Domenic 
Denicola
- show quoted text -
>  Unless I'm missing something (quite possible!), I would prefer not to add 
new methods to Map and Set when they could be added to %IteratorPrototype%.

Yeah, I'm missing something. It's the difference in code between:

```js
var newMap = oldMap.map(([k, v]) =>  [k+ 1,  v+ 1]);
```

versus

```js
var newMap = new Map(oldMap.entries().map((([k, v]) =>  [k+ 1,  v+ 1]);

But entries returns an iterator, and if we define %IteratorPrototype% to create a new instance of the right class given its |this| parameter, in this case Map and not MapIterator, then no need for the new Map() wrapper.

I think I still prefer avoiding every iterable subclass adding its own 
map/filter/etc. in favor of people using the compositional base primitives, but 
at least I see the argument now.

I point out in https://www.w3.org/Bugs/Public/show_bug.cgi?id=26973#c3 that the lack of Map.prototype.{map,filter,...} doesn't bite when you use for-of, but of course will be missed when you want to call someMap.filter directly. Which is reasonable to do!

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to