Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Created February 3, 2017 18:41
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 ghaiklor/9abac5a6efb24829312c755c88713519 to your computer and use it in GitHub Desktop.
Save ghaiklor/9abac5a6efb24829312c755c88713519 to your computer and use it in GitHub Desktop.
Module.prototype.load sources
// Given a file name, pass it to the proper extension handler.
Module.prototype.load = function(filename) {
debug('load %j for module %j', filename, this.id);
assert(!this.loaded);
this.filename = filename;
this.paths = Module._nodeModulePaths(path.dirname(filename));
var extension = path.extname(filename) || '.js';
if (!Module._extensions[extension]) extension = '.js';
Module._extensions[extension](this, filename);
this.loaded = true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment