I need a function in main.js (the script that is running) to be recognized in the scope of the modules:
Modules.js:
function x(){
functionNeeded();
}
module.export.x = x;
Main.js
var m = require("modules.js");
function functionNeeded(){
//function needed to call
}
//m.x() is called successfully
//but fails because functionNeeded is not defined (check modules.js)
//with m.functionNeeded = functionNeeded before calling m.x() it also fails.
Does anyone have any idea on how can this achieve so I can spread a function of main.js across several modules without duplicating it or spreading it across the modules?
functionNeeded()in its own module which module.js canrequire()in or you can pass it in tox()as a callback.