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

Already on GitHub? Sign in to your account

add eachIndex/forEachIndex function with tests #264

wants to merge 3 commits into


None yet
4 participants

I've added a new function eachIndex with forEachIndex alias that does exactly what each function does. The difference is in the number of arguments the iterators accept.

function eachIterator(val, callback) {...}
function eachIndexIterator(val, index, callback) {...}

The iterator for eachIndex accepts additional index argument which indicates on the index in the array that val is.

This functionality was necessary for me when I needed to distinguish the values of the supplied array based on their position in the array.

I hope this function will be useful for others as well.


brianmaissy commented Mar 11, 2013

This and #168 seem to be duplicates of each other

As I see forEachOf is applicable for Objects while eachIndex is for Arrays which async natively works with. I see a way to merge these two functionalities, though.


brianmaissy commented Mar 11, 2013

In the discussion there it is proposed to have forEachOf support both objects and arrays

Any plans to accept forEachOf?


brianmaissy commented Mar 11, 2013

Thats a good question. @caolan, whats the status of that? I think the last activity there was @dominicbarnes asked you to review a partial implementation.

What's the status of this being merged into master? And why have several other requests for the same feature been incorrectly closed as being duplicates of an issue that's asking for iterating over object properties, not providing the index in an array that the item sent to the iterator came from?

@juanpaco juanpaco referenced this pull request Jan 7, 2014


get the key in async.each? #380


caolan commented Mar 28, 2014

closing in preference of forEachOf

@caolan caolan closed this Mar 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment