Node.JS Module Patterns

1. The simplest module

2.Module Patterns
2.1. Define a global

Node: Don’t pollute the global space

2.2. Export an anonymous function

2.3. Export a named function

2.4. Export an anonymous object

2.5. Export a named object

2.6. Export an anonymous prototype

2.7. Export a named prototype

3.Summary:

  • Named exports – allow you to export multiple ‘things’ from a single module
  • Anonymous exports – simpler client interface

http://www.commonjs.org/specs/modules/1.0/