-
-
Save bhurlow/4248545 to your computer and use it in GitHub Desktop.
My Node.js modules these days
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assets | |
// first installed modules | |
var util = require('util') | |
var assert = require('assert') | |
var whatever = require('whatever') | |
// then local | |
var foo = require('./foo') | |
var bar = require('./bar') | |
// main export | |
module.exports = the_exported_function | |
module.exports.extra = extra | |
module.exports.other = other | |
var ENABLE_BUGS = false | |
, MODE = 'production' | |
function the_exported_function() { | |
} | |
function extra() { | |
} | |
function other() { | |
} | |
function main() { | |
} | |
// IF RUN DIRECTLY via node <filename>.js | |
if(require.main === module) { | |
// do stuff here | |
} | |
// otherwise its a module | |
else { | |
module.exports = the_exported_function | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment