Forwarding `return()` in generators

Bergi a.d.bergi at
Thu Mar 26 22:48:15 UTC 2015

Axel Rauschmayer wrote:
> a difference between iterators that you have to be aware of and that needs to be documented per iterable.

Alternatively, just test `if (typeof iterator.return == "function")` :-)
But yes, awareness is required. Maybe we should dub "closeable 
iterators" as a subtype of the iterator interface?

> It’d be great if all iterables were indeed the same in this regard.

What do you suggest, that array iterators should not be continuable? So 
we'd have `.return()` methods on ArrayIterators, StringIterators, 
MapIterators, and SetIterators, which sets the respective [[Iterated*]] 
internal property to `undefined`?


More information about the es-discuss mailing list