Skip to content

Instantly share code, notes, and snippets.

@adrianlee
Created June 21, 2012 04:45
Show Gist options
  • Save adrianlee/2963880 to your computer and use it in GitHub Desktop.
Save adrianlee/2963880 to your computer and use it in GitHub Desktop.
testing an object which is shared between all instances of the current module and made accessible through require()
var b = require('./b');
var b2 = require('./b');
console.log(b.test());
console.log(b2.test());
console.log("-----");
b.omg();
console.log(b.test());
console.log(b2.test());
var hello = "hello";
module.exports = {
test: function () {
return hello;
},
omg: function () {
hello = "hello_modified";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment