Created
February 7, 2012 09:07
-
-
Save markdaws/1758429 to your computer and use it in GitHub Desktop.
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
// common.js ====================================== | |
exports.foo = function() { | |
return 'bar'; | |
} | |
// ================================================ | |
// anotherfile.js ================================= | |
var common = require('common'); | |
console.log(common.foo()); | |
// ================================================ | |
// when common.js is loaded, node wraps it in a function definition | |
// and passed in an exports object e.g. | |
function (exports, require, module, __filename, __dirname) { | |
exports.foo = function() { | |
return 'bar'; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment