I am writing a javascript framework using the module pattern, which looks like this:
var EF = (function(doc) {
// Main public object
var e = {
version: "1.0.0",
doc: doc,
log: true
};
// Private methods
var method1 = function(el) {
<some code>
}
var method2 = function(el) {
<some code>
}
var method3 = function(el) {
<some code>
}
// PUBLIC METHODS ASSIGNMENT
e.method1 = method1;
e.method2 = method2;
e.method3 = method3;
return e;
}(document));
Now I decided that I should move some methods to the separate file. During development I then would load two files one by one in the HTML file, while for deployment I would merge them in a single file.
What is the correct way move part of the methods to a separate files keeping the structure of the code that I use?
I've seen the following suggestion in one of the answers on stackoverflow:
var MODULE = (function (my) {
var privateToThisFile = "something";
// add capabilities...
my.publicProperty = "something";
return my;
}(MODULE || {}));
It looks almost like what I need, but it shows private methods for the file and for the module. But I need private methods for the module and pubic methods for the module.
What suggestions would you have?