Skip to content

Instantly share code, notes, and snippets.

@zerokarmaleft
Created July 4, 2012 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerokarmaleft/3044959 to your computer and use it in GitHub Desktop.
Save zerokarmaleft/3044959 to your computer and use it in GitHub Desktop.
defining node.js modules
(function() {
var Foo;
Foo = (function() {
function Foo() {
// initialize properties
}
// instance methods
Foo.prototype.bar = function() {};
Foo.prototype.baz = function() {};
return Foo;
})();
exports.Foo = function() {
return new Foo();
};
}).call(this);
var foo = require('foo');
var foo_instance = foo.Foo();
foo_instance.bar();
foo_instance.baz();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment