I can access node global variables as property of GLOBAL object.
can I access module scope variables in similar way?
e.g.
var fns_x = function(){/*...*/};
var fns_y = function(){/*...*/};
function aFn(param){
/* moduleScope = something that allows me to access module scope variables */
if(moduleScope['fns_' + param]){
moduleScope['fns_' + param]();
}
}
/*...*/
module.exports = /*...*/
Or it's better to wrap those variables in object? e.g.
var fns = {
x: x = function(){/*...*/},
y: x = function(){/*...*/}
}
function aFn(param){
if(fns[param]){
fns[param]();
}
}
/*...*/
module.exports = /*...*/
fns(modify the 2nd example a little)? I don't see the need for the function that checks if the functions have been declared.