Skip to content

Instantly share code, notes, and snippets.

@jjmalina
Forked from jhs/example.js
Created March 12, 2013 23:23
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 jjmalina/5148021 to your computer and use it in GitHub Desktop.
Save jjmalina/5148021 to your computer and use it in GitHub Desktop.
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
var whatever = require('whatever') // churn in Git.
//
var foo = require('./foo') // Modules within this package
var bar = require('./bar') //
//
var ENABLE_BUGS = false // Globals in the module, upper-case
, MODE = 'production' // I like comman-first. YMMV.
// (Two blank lines)
//
function the_exported_function() { // The primary API entry point, either
} // a function or constructor.
//
function extra() { // Some other optional API function
} //
//
function other() { // Some other optional API function
} //
// (Two blank lines)
//
function main() { // Optional main function for CLI
} // execution.
//
if(require.main === module) // Run main() if this module is
main() // executed rather than required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment