passing parameters to Node.js async waterfall

3.7k Views Asked by At

I need to pass some parameters to the initial function of async waterfall(). The proposed method https://github.com/caolan/async/issues/14 does not work for me as I need to pass it the response from an ExpressJS function

exports.categories = (req, res) ->
    async.waterfall [           
       (callback) ->
         # need req here...
2

There are 2 best solutions below

0
On BEST ANSWER
async.waterfall [
  ( (req, callback) ->

  ).bind(null, req)
]
1
On

See async.apply().

async.waterfall([
  async.apply(function(req, callback) {}, req);
]);