I have a fairly large function in my module (./myMainModule.js) that I would like to be packaged in a separate module (./mySubModule. I'm trying to figure out how to require(mySubModule) and then have a function from mySubModule be used as a function in myMainModule.
I've tried to export
mainFunction: mySubModule.subFunction(params),
but it's saying the params are not defined.
//myMainModule.js
const mySubModule = require("./mySubModule)
module.exports = {
mainFunction: mySubModule.subFunction(params),
}
//----------
//mySubModule.js
module.exports {
subFunction: function(params) {
console.log(params);
}
}
I'm getting params is not defined when assigning the function in myMainModule.
=is missing in mySubmodule... it should bemodule.exports = {paramsvalue?) when you want to export the function itself, not the result of a call.