Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no @@iterator method on iterators? #37

Open
jaawerth opened this issue Sep 4, 2015 · 2 comments · May be fixed by #44
Open

no @@iterator method on iterators? #37

jaawerth opened this issue Sep 4, 2015 · 2 comments · May be fixed by #44

Comments

@jaawerth
Copy link

jaawerth commented Sep 4, 2015

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;
  }
}
@jlongster
Copy link
Owner

You're right, it looks like that should exist. Feel free to send a PR!

@jaawerth
Copy link
Author

jaawerth commented Sep 5, 2015

Done!

@jaawerth jaawerth linked a pull request Mar 29, 2017 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants