This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
http://heycam.github.io/webidl/#es-iterator-prototype-object [[ The internal [[Prototype]] property of an iterator prototype object MUST be the Object.prototype object. ]] http://lists.w3.org/Archives/Public/public-script-coord/2014OctDec/0058.html points out that iterator objects in ES6 all inhert from %IteratorPrototype%, so we should do the same with iterator prototype objects generated for iterable declarations.
The plan is to put much-wanted methods on Iterator.prototype, in ES7. The iteration protocol in JS is still structural, but Iterator() provides an adapter from structural to nominal, with map/filter/etc. handy methods via prototypal inheritance. Dave should correct me on anything amiss here. I hope this helps improve the web platform sooner. /be
Yeah, having generic map/filter that apply to any iterable and live on Iterator.prototype (and perhaps some prototypes of other iterables like Set and Map) would be really nice!
(In reply to Boris Zbarsky from comment #2) > Yeah, having generic map/filter that apply to any iterable and live on > Iterator.prototype (and perhaps some prototypes of other iterables like Set > and Map) would be really nice! Iterator not iterable, so if Map and Set have standard iterators that delegate to Iterator.prototype, then everything works automagically. You name a map or set on the right of for-of's 'of' and @@iterator does the rest. Having Map.prototype.map do the @@iterator call and delegate to the returned iterator's map is doable but seems unnecessary when using for-of. When calling someMap.filter directly, of course, it's wanted. Some design freedom here to "do both", IMHO. /be
This would mean that you would write things like: myMap.keys().filter((x) => x > 10) yeah? To make it a little easier to type than: [...myMap.keys()].filter((x) => x > 10)
(In reply to Cameron McCormack from comment #4) > This would mean that you would write things like: > > myMap.keys().filter((x) => x > 10) > > yeah? To make it a little easier to type than: > > [...myMap.keys()].filter((x) => x > 10) Yes, and more efficient too. (BTW the single-parameter arrow function form does not need parens around the formal parameter: x => x > 10 -- just passing this along in case it needs some publicity. ;-) /be
This appears to have been fixed a while ago.