Last active
December 25, 2015 03:49
-
-
Save kixorz/6913097 to your computer and use it in GitHub Desktop.
Example of design pattern for Node.js modules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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