Skip to content

Instantly share code, notes, and snippets.

Created Jul 6, 2015
What would you like to do?
node module closure
$ node
> var m = require('module');
> require.toString()
'function require(path) {\n return self.require(path);\n }'
> module.require.toString()
'function (path) {\n assert(path, \'missing path\');\n assert(util.isString(path), \'path must be a string\');\n return Module._load(path, this);\n}'
> m.wrapper
[ '(function (exports, require, module, __filename, __dirname) { ',
'\n});' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment