Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module: rename anonymous functions #13849

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function tryExtensions(p, exts, isMain) {
}

var warned = false;
Module._findPath = function(request, paths, isMain) {
Module._findPath = function _findPath(request, paths, isMain) {
if (path.isAbsolute(request)) {
paths = [''];
} else if (!paths || paths.length === 0) {
Expand Down Expand Up @@ -243,7 +243,7 @@ var nmChars = [ 115, 101, 108, 117, 100, 111, 109, 95, 101, 100, 111, 110 ];
var nmLen = nmChars.length;
if (process.platform === 'win32') {
// 'from' is the __dirname of the module.
Module._nodeModulePaths = function(from) {
Module._nodeModulePaths = function _nodeModulePaths(from) {
// guarantee that 'from' is absolute.
from = path.resolve(from);

Expand Down Expand Up @@ -285,7 +285,7 @@ if (process.platform === 'win32') {
};
} else { // posix
// 'from' is the __dirname of the module.
Module._nodeModulePaths = function(from) {
Module._nodeModulePaths = function _nodeModulePaths(from) {
// guarantee that 'from' is absolute.
from = path.resolve(from);
// Return early not only to avoid unnecessary work, but to *avoid* returning
Expand Down Expand Up @@ -326,7 +326,7 @@ if (process.platform === 'win32') {
// 'index.' character codes
var indexChars = [ 105, 110, 100, 101, 120, 46 ];
var indexLen = indexChars.length;
Module._resolveLookupPaths = function(request, parent, newReturn) {
Module._resolveLookupPaths = function _resolveLookupPaths(request, parent, newReturn) {
if (NativeModule.nonInternalExists(request)) {
debug('looking for %j in []', request);
return (newReturn ? null : [request, []]);
Expand Down Expand Up @@ -429,7 +429,7 @@ Module._resolveLookupPaths = function(request, parent, newReturn) {
// 3. Otherwise, create a new module for the file and save it to the cache.
// Then have it load the file contents before returning its exports
// object.
Module._load = function(request, parent, isMain) {
Module._load = function _load(request, parent, isMain) {
if (parent) {
debug('Module._load REQUEST %s parent: %s', request, parent.id);
}
Expand Down Expand Up @@ -472,7 +472,7 @@ function tryModuleLoad(module, filename) {
}
}

Module._resolveFilename = function(request, parent, isMain) {
Module._resolveFilename = function _resolveFilename(request, parent, isMain) {
if (NativeModule.nonInternalExists(request)) {
return request;
}
Expand All @@ -491,7 +491,7 @@ Module._resolveFilename = function(request, parent, isMain) {


// Given a file name, pass it to the proper extension handler.
Module.prototype.load = function(filename) {
Module.prototype.load = function load(filename) {
debug('load %j for module %j', filename, this.id);

assert(!this.loaded);
Expand All @@ -507,7 +507,7 @@ Module.prototype.load = function(filename) {

// Loads a module at the given file path. Returns that module's
// `exports` property.
Module.prototype.require = function(path) {
Module.prototype.require = function require(path) {
assert(path, 'missing path');
assert(typeof path === 'string', 'path must be a string');
return Module._load(path, this, /* isMain */ false);
Expand All @@ -523,7 +523,7 @@ var resolvedArgv;
// the correct helper variables (require, module, exports) to
// the file.
// Returns exception, if any.
Module.prototype._compile = function(content, filename) {
Module.prototype._compile = function _compile(content, filename) {

content = internalModule.stripShebang(content);

Expand Down Expand Up @@ -575,14 +575,14 @@ Module.prototype._compile = function(content, filename) {


// Native extension for .js
Module._extensions['.js'] = function(module, filename) {
Module._extensions['.js'] = function _extensionsJS(module, filename) {
var content = fs.readFileSync(filename, 'utf8');
module._compile(internalModule.stripBOM(content), filename);
};


// Native extension for .json
Module._extensions['.json'] = function(module, filename) {
Module._extensions['.json'] = function _extensionsJSON(module, filename) {
var content = fs.readFileSync(filename, 'utf8');
try {
module.exports = JSON.parse(internalModule.stripBOM(content));
Expand All @@ -594,20 +594,20 @@ Module._extensions['.json'] = function(module, filename) {


//Native extension for .node
Module._extensions['.node'] = function(module, filename) {
Module._extensions['.node'] = function _extensionsNode(module, filename) {
return process.dlopen(module, path._makeLong(filename));
};


// bootstrap main module.
Module.runMain = function() {
Module.runMain = function runMain() {
// Load the main module--the command line argument.
Module._load(process.argv[1], null, true);
// Handle any nextTicks added in the first tick of the program
process._tickCallback();
};

Module._initPaths = function() {
Module._initPaths = function _initPaths() {
const isWindows = process.platform === 'win32';

var homeDir;
Expand Down Expand Up @@ -635,7 +635,7 @@ Module._initPaths = function() {

var nodePath = process.env['NODE_PATH'];
if (nodePath) {
paths = nodePath.split(path.delimiter).filter(function(path) {
paths = nodePath.split(path.delimiter).filter(function pathsFilterCallback(path) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the only one that's necessary. The rest should show up as expected in stack traces, etc. because they're attached to an object (prototype or otherwise).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this is the only one that is needed. Can you please restore the other ones?

return !!path;
}).concat(paths);
}
Expand All @@ -646,7 +646,7 @@ Module._initPaths = function() {
Module.globalPaths = modulePaths.slice(0);
};

Module._preloadModules = function(requests) {
Module._preloadModules = function _preloadModules(requests) {
if (!Array.isArray(requests))
return;

Expand Down