Skip to content

Instantly share code, notes, and snippets.

@dkolb

dkolb/a.js

Last active Dec 24, 2015
Embed
What would you like to do?
Node.js Module Globals Example
var b = require(__dirname + "/b"),
c = require(__dirname + "/c");
b.doIt();
console.log(c.get()); //Outputs 'b.doIt is updating stuff!'
var c = require(__dirname + '/c');
module.exports.doIt = function() {
c.update("b.doIt is updating stuff!");
}
var x;
module.exports.update = function(y) {
x = y;
}
module.exports.get = function() {
return x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.