I am working with Node.js streams and end up with something like this in several places:
var myVariable = 'XXX';
...
.on('end', function() {
// do something with myVariable
});
The behaviour of the function is the same but depends on a variable so I would like to refactor it to:
var myVariable = 'XXX';
...
.on('end', myFunction);
function myFunction(param){
// do something with param
}
How can I pass the value of myVariable in the call .on('end', myFunction);?
paramfrom?endevent?