Skip to content

no @@iterator method on iterators? #37

@jaawerth

Description

@jaawerth

Hey there!

I noticed that iterators produced by the toIter and iterator methods don't have a Symbol.iterator/@@iterator method on them and thus won't work with for..in, yield*, new Set(), etc. This is mentioned in the comments as part of iterator protocol, so before I submit a PR I was wondering: is that an intentional omission?

It'd be nice to have in ES6, so the resultant iterators can be used with things like

function* flatten(iterable) {
  for (let item of iterable) {
    if (item[Symbol.iterator]) yield* flatten(item);
    yield item;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions