Skip to content

Instantly share code, notes, and snippets.

@fritx
Created February 15, 2014 06:24
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 fritx/9015318 to your computer and use it in GitHub Desktop.
Save fritx/9015318 to your computer and use it in GitHub Desktop.
`requireFn` with circular module loading
/**
* Created by fritz on 2/15/14.
*/
var Module = require('module'),
path = require('path');
/**
* easy way for circular module loading
*/
function requireFn(request) {
return function () {
var parent = module.parent,
name = Module._resolveFilename(request, parent);
return require(name);
};
}
module.exports = requireFn;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment