I have a function exposed through export in a node module I'm building. I'd like to be able to have that function call an internal (private) function within the same module.
So far I have something like:
someModule.js
var publicFunc = function(a, b) {
var obj = {result: 'of some processing'};
return privateFunc(obj);
}
var privateFunc = function(obj) {
/* proccessing */
return result;
}
exports.publicFunc = publicFunc;
When publicFunc calls privateFunc I get:
Reference error: privateFunc is not defined;
Change your declarations to function name(... instead of var name = function(...
function publicFunc(a, b) {
var obj = {result: 'of some processing'};
return privateFunc(obj);
}
function privateFunc (obj) {
/* proccessing */
return result;
}
exports.publicFunc = publicFunc;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With