-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Adds support for es6 iterators #1074
Conversation
if (item.done) | ||
return null; | ||
i++; | ||
return map ? {value: item.value[1], key: item.value[0]} : {value: item.value, key: i}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is map the only time we'd like to do this switch? Also not sure if tracking indexs even makes sense for a *Map
as they won't correspond to the actual index (can't do map[1]
to get item.value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a valid thing to do. I think it's odd to iterate over a map and get [key, val]
as the value with an arbitrary numeric index.
@megawac if wan't use map's indexes it makes iterator easy - just replace to lodash.prototype.next() |
We are not going to import lodash chaining |
@megawac corrected. |
This is really cool. 👍 |
Damn, I was looking for some precedent in how to handle It does seem weird to have a special case just for |
I disagree, if they want keys they should pass |
var item = iterate.next(); | ||
if (item.done) | ||
return null; | ||
i++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like tracking this index. People should pass .entries
if they want access to the key
. i
may not correspond to the real index. Just leave key
undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some sort of index is needed for map(Series|Limit)
to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point fine with this then
@megawac @aearly FYI