-
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
Feature Request: Foreach with the object key please #26
Comments
Ultimately, the problem is the long list of arguments the callbacks would need to support, every callback would look like: function (obj, index, arr, callback) { ... } Even though in most circumstances you wouldn't need to use the additional parameters. One solution is to detect the number of arguments the callback function accepts and just pass that number of variables to it, always providing the callback as the last one. This is something I've been exploring, see the nimble project for an example of how that might work: http://caolan.github.com/nimble And for an explanation of the technique: http://caolanmcmahon.com/posts/flexible_callback_arguments It seems to be working nicely so far. Provided I don't run into any major issues with it I may add it to the async library. Unfortunately it would mean some backwards-incompatible changes, so it would need to be on the next major version. For now, perhaps nimble would work for you? |
@caolan, nimble does indeed iterate over object values, but async's forEach[Series] doesn't. Any reason why this is the case? Also seen issue #13 point this out directly. It seems we're only using the 'nimble' subset of async so we might eventually just switch. While it's not explicitly documented on http://caolan.github.com/nimble, all functional constructs ( UPDATE: we're actually using UPDATE2: nevermind, we do need the keys as well, so resorting to nimble for now. +1 for checking the arity of the callback function and using flexible callback arguments in the next major version. Any release roadmap? :) |
I like the way the module forEachAsync does it. The callback is always the first parameter in the callback for each element in the array.
I don't however, like the The issue is, this would totally break backwards compat, and make this module inconsistent with the rest of async's methods. Is this a big enough deal to warrant a major API change? |
This is a duplicate of #168 and should be closed. |
Hi,
I realy like your module cause it makes my life much easier :)
But, following example:
The text was updated successfully, but these errors were encountered: