Created
February 15, 2014 06:24
-
-
Save fritx/9015318 to your computer and use it in GitHub Desktop.
`requireFn` with circular module loading
This file contains hidden or 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
/** | |
* 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