Currently I have this structure:
(function(myScope) {
myScope.public = function() {alert("I'm public!")};
myScope.privileged = function() {alert("I can call private!"); private();};
var private = function() {alert("I'm private!")};
})(window.myObj);
It works fine. private
is not accessible from the outside world while privileged
can call it. But now the private parts are too big such that I hope to extract it out. I want to keep it inaccessible from the outside but it needs to be invoked by the privileged functions. Is there a way to achieve that?
UPDATE:
The above is just an example. The general problem is that as the app extends, the single js file grows to become long and unmanageable. The goal is to split such js file into module, without compromising privacy.