This is the module pattern:
var module1 = (function(){
// private variable
var private_var;
// private method
var private_method = function(){
// ...
}
// public interface
return {
// A public variable
publicVar: "foo",
// A public function utilizing privates
publicMethod: function( bar ) {
// ..
}
})()
I've found a similar pattern where the return value is not an object but a function:
var module2 = (function(){
// private variable
var private_var;
// private method
var private_method = function(){
// ...
}
// this is supposed to be a shortcut for me.doThings
var me = function (options) {
me.doThings(options);
}
me.doThings = function(options) {
// do something
}
// returns a function instead of an object
return me;
})()
used like this: module2(options).
me is in fact a shortcut for the me.doThings function.
I'm confused if this could be considered a Module pattern at all. And what would be the main differences and use cases between module1 and module2