Reputation: 8977
async.eachLimit(rowset.rows, 200, storeRow, postProcessingFunction);
function storeRow(row, cb) {...}
How to pass an additional param to storeRow()
?
So something like this :
async.eachLimit(rowset.rows, 200, storeRow, rowset.param, postProcessingFunction);
function storeRow(row, param, cb) {...}
Upvotes: 1
Views: 477
Reputation: 17357
Use Function.bind to create a "curried" function.
function storeRow(propertyFromRowset, row, cb){ /* ... */ };
async.eachLimit(
rowset.rows,
200,
storeRow.bind(null,rowset.property),
postProcessingFunction
);
See Wikipedia:Currying for the theory and Function.prototype.bind for details of how to curry a function in Javascript.
Upvotes: 0
Reputation: 66989
You probably don't need to do it that way. Instead, you could do something like this:
function foo(param) {
async.eachLimit(rowset, 200, storeRow, postProcessingFunction);
function storeRow(row, cb) { /* this code uses param */ }
}
Upvotes: 1