generator function requirements

# Mark Volkmann (10 years ago)

I couldn't find this in spec. Is it required for generator functions to return an object that is both iterable (has Symbol.iterator method) and an iterator (has next method). It seems Babel does this, but I want verify whether that is required.

# Rick Waldron (10 years ago)

The object that's returned by a generator function conforms to both the Iterator and Iterable interfaces.

# Dmitry Soshnikov (10 years ago)

On Sun, Apr 12, 2015 at 4:53 PM, Rick Waldron <waldron.rick at gmail.com> wrote:

The object that's returned by a generator function conforms to both the Iterator and Iterable interfaces.

As any other iterator of the built-ins (unless I'm not aware of specific cases). I.e. an enough description is: an object is returned by a generator function is an iterator (and that it conforms also the iterable interfaces this should go without saying, since all iterators do; user-level iterators may deviate from this "invariant" though).

# Rick Waldron (10 years ago)

On Sun, Apr 12, 2015 at 8:08 PM Mark Volkmann <r.mark.volkmann at gmail.com> wrote:

Thanks! I suspected that, but wanted to confirm it. Do you see in the spec where is says that generators are required to implement both of those interfaces?

Yep, you're looking for "Generator Objects" people.mozilla.org/~jorendorff/es6-draft.html#sec-generator-objects