Reputation: 62
I want to understand the difference between writing javascript code in Node module style and revealing module pattern.
I have used revealing module pattern but I recently read about writing node modules and invoking the js file using the require function and calling the public methods of the node module. How is this different from revealing module pattern?
Upvotes: 1
Views: 631
Reputation: 40525
There is some interesting discussion on this point here, especially in the comments.
The revealing pattern is a useful way to protect the inner workings of a module and only expose what you want to. The gist of the comments in that blog article are that Node's module.exports
approach is enough because Node will automatically wrap up any module code you write anyway.
Upvotes: 1