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

iterator support for _.toArray #2448

Open
jdalton opened this issue Feb 27, 2016 · 5 comments
Open

iterator support for _.toArray #2448

jdalton opened this issue Feb 27, 2016 · 5 comments

Comments

@jdalton
Copy link
Contributor

jdalton commented Feb 27, 2016

I think support for converting iterators to arrays would be a nice to have for _.toArray.

@anthony-redFox
Copy link

@jdalton Do you mean Array.from ?
I think, it is should be like polyfill Array.from

@jdalton
Copy link
Contributor Author

jdalton commented Feb 29, 2016

Do you mean Array.from ?

I mean something like iteratorToArray which can be used as part of toArray.
Browsers like IE11 have support for Map and Set without support for Array.from.

I think, it is should be like polyfill Array.from

Ya I get that, but _.toArray has more features. The addition of iterator support would round it out.

Array.from({ 'a': 1 })
// => []
_.toArray({ 'a': 1 })
// => [1]

@akre54
Copy link
Collaborator

akre54 commented Feb 29, 2016

Rather than reimplementing toArray why don't we just call Array.from if it exists? You probably wouldn't / shouldn't be using iterators if you haven't polyfilled Array.from.

@jdalton
Copy link
Contributor Author

jdalton commented Feb 29, 2016

You probably wouldn't / shouldn't be using iterators if you haven't polyfilled Array.from.

Because Array.from isn't a requirement for iterator conversion and there are environments without it where maps and sets and other iterables work fine. So it would be inconsistent support.

The lines savings aren't worth the inconsistent support.
We're talking about 4 or 5 LOC (less than 100 bytes). Nothing major.

IE11's market share for reference:
marke tshare

@jgonggrijp
Copy link
Collaborator

Will only make sense if combined with #2147.

@jgonggrijp jgonggrijp linked a pull request Dec 17, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants