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
How can I dynamically push functions with different arguments to an array? I need to process those functions using Async.js (parallel or race mode) #1104
Comments
Lots of stuff here, including basic JS variable scoping quirks. The short answer to your question is that you can use async.map([1, 2, 3, 4], function(x, callback){
callback(null,calculate(x))
}, function(err,result){
if (err) {
console.log(err);
return;
}
console.log("Results are: " + result);
}); But the real answer is that you don't need Async at all: var result = [1, 2, 3, 4].map(calculate) |
Thank you very much ... Sent from my iPhone
|
Hi Caolan, Lots of stuff here, including basic JS variable scoping quirks. The short answer to your question is that you can use async.map, it runs in parallel too: async.map([1, 2, 3, 4], function(x, callback){ But the real answer is that you don't need Async at all: var result = [1, 2, 3, 4].map(calculate) — |
Hi Caolan, Thank you so much for the help, it worked perfectly, however I would like to know how I can implement the "race" mode. I already tried several times and I am getting errors. Regards, |
Currently I am trying to run in parallel the same function with different arguments using Node.JS
For this I use Async.js and i am struggling trying to push/stack functions to an array.
The problem is that the functions are executed with the same arguments. This is what I have:
Any idea?
Thanks
The text was updated successfully, but these errors were encountered: