Created
December 19, 2010 11:42
-
-
Save dominictarr/747281 to your computer and use it in GitHub Desktop.
module where globals === this
This file contains 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
console.log("GLOBALS!") | |
var assert = require('assert') | |
this.hello = 'sdgfasdgaghasdg' | |
assert.ok(global === this,'expected global === this') | |
assert.equal(this.hello , hello) | |
y = 'MVOISMDFOVISR' | |
assert.equal(this.y , 'MVOISMDFOVISR') |
This file contains 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
//loader | |
require.extensions['.this-js'] = | |
function (module, filename) { | |
var content = require('fs').readFileSync(filename, 'utf8'); | |
var newContent = "var globalizer = function () {" | |
+ content | |
+ "};\n globalizer.apply(global)" | |
module._compile(newContent, filename); | |
} | |
require('./globals') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment