1
votes

Node.js has one thing like this async modules. Does anyone know - how to organize something like this :

async.map(['file1','file2','file3'], fs.stat, function(err, results){
      // results is now an array of stats for each file
});

Currently I'm using a Play Framework/Scala

1
What would be the type of fs.stat in this case? - Patryk Ćwiek
I think using Future with Action.async could be solution here. I am not sure in what context you want to use this. - Łukasz
@PatrykĆwiek function for each values - Lola
@Maria What function? A => Future[B]? Or A => B? The second one doesn't really make much sense in this context, but if you already have async processing for every element, you can simply do Future.sequence(files.map(fn)).map(results => ...) - Patryk Ćwiek

1 Answers

0
votes

Provided you find the equivalent of fs.stat (I don't think it is the purpose of your question), you can use Parallel Collections. You would get something like this:

Vector("file1","file2","file3").par.map(f => function(fs.stat(f)))