Skip to content

Instantly share code, notes, and snippets.

@jhgaylor
Created May 17, 2014 02:55
Show Gist options
  • Save jhgaylor/9ef99b1be4ea2a22043a to your computer and use it in GitHub Desktop.
Save jhgaylor/9ef99b1be4ea2a22043a to your computer and use it in GitHub Desktop.
// Include some libraries
var Twit = require('twit');
var _ = require('underscore');
// Module pattern
// http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
// This is a Immediately Invoked Function Expression (IIFE)
// tho i'll probably call it a self executing anonymous function
// It's used to create a new scope so that
// we don't muddy up the global namespace building our module
var DataCollector = (function (Twit, _) {
// Jane is just an internal name for the collector. This fn
// is the return value of the IIFE.
var Jane = function () {
};
// any variables declared within this closure
// are available for use by any other code in the closure
// (closures are kind of like lets in other languages)
var private_method = function () {
};
// methods on the prototype of a function are available
// on the object returned by `new Fn()`
// they are essentially public methods
Jane.prototype.public_instance_method = function () {
};
return Jane;
})(Twit, _);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment