Skip to content

Instantly share code, notes, and snippets.

@kixorz
Last active December 25, 2015 03:49
Show Gist options
  • Select an option

  • Save kixorz/6913097 to your computer and use it in GitHub Desktop.

Select an option

Save kixorz/6913097 to your computer and use it in GitHub Desktop.
Example of design pattern for Node.js modules.
var module1 = function(param1, param2) {
var m_param1 = param1;
var m_param2 = param2;
var private_method = function(param3) {
return param3 + m_param1 + m_param2;
};
return {
public_method1: function(param1) {
return private_method(param1);
}
};
};
module.exports = module1;
var module1 = require('./module1')(param1, param2);
var result = module1.public_method1(param3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment