Pergunta

I have a set of functions that are independent of each other [each of them returns a value, each of these functions also accept parameters.] and I wish to run them in parallel. If i use async.parallel I wont have the liberty to catch the values. Is there a way to do this?

Thanks.

Foi útil?

Solução

Example of how to do this in CoffeeScript:

async = require "async"
fns = [
   (cb) -> cb 1
   (cb) -> cb 2
   (cb) -> cb 4
]

async.parallel fns, (results) ->
  console.log results
  # produces [1,2,4]
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top