-
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
forEach with object + key in iterator #72
Comments
Yes, the reason being I didn't want to require each iterator to accept This is something I'd like to support in async in the future, but I |
You could start a new 'postfix', like a forEachAt(), or just eachAt() or something. Whole point for this one would be to have that list + key + value in the iterator so it sort of specifically would break pattern, and and this could indicate it maybe? |
+1. I really need my keys :) Any plans to implement this? I could write a pull request. |
I would also like this functionality. I think @Bartvds's way is least intrusive, but maybe use the |
I was editing some code I had written synchronously with underscore.js (aren't we all :), and wanted to swap sync stuff out for some async goodness. But I found a conceptual mismatch: Underscore's ._each() has a function(value, key, list) iterator format, async only has a (value, callback): it's 'missing' the key +list.
Having the hash, key, value inside the iterator is very useful if you need a bit more then just a basic map()-like. Right now the iterator has no way of knowing where in the input collection the current value would fit or what it's key was. Which is fine when you just update the same collection (map() etc), but when you need the key for something else beside the looping it get's ackward.
Now I do a _.keys() and pull that through some other async stuff. It's nearly the same and works but it's not in the spirit of things no? :)
(edit: if I gathered enough courage I might attempt a fork/edit/pull but no promises :)
The text was updated successfully, but these errors were encountered: