Skip to content

Instantly share code, notes, and snippets.

@tdantas
Created July 6, 2015 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdantas/aa31c677722ad837661a to your computer and use it in GitHub Desktop.
Save tdantas/aa31c677722ad837661a to your computer and use it in GitHub Desktop.
node module closure
$ node
> var m = require('module');
undefined
> 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