-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
net: refactor net module to module.exports #11698
net: refactor net module to module.exports #11698
Conversation
@@ -59,7 +59,7 @@ exports.createServer = function(options, connectionListener) { | |||
// connect(port, [host], [cb]) | |||
// connect(path, [cb]); | |||
// | |||
exports.connect = exports.createConnection = function() { | |||
function connect() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we just called this createConnection()
and added the connect: createConnection
alias in the export list. This way we won't have to rename connect
to internalConnect
everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd still have a "connect" in the exports (i.e. part of the module's API) and a function named "connect" in the code that is not the same as the export, which is still IMHO confusing. Also there's no change in the public API, no need to rename anything outside of this module. Also references inside the module to a "connect" function that is not the same as the export are confusing.
internalConnect
might not be the best name though, I admit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internalConnect
does make grepping easier.
55932b5
to
e34d96d
Compare
e34d96d
to
e41a3c3
Compare
Refactor net module to use the more efficient module.exports = {} pattern. Also renames internal "connect" function to "internalConnect" to avoid collision with exported "connect".
Rebased and fixed linting error in lib/net, but there's a bunch of other linter errors in some addons tests in the branch when I run |
Those should be unrelated to this PR.. New CI: https://ci.nodejs.org/job/node-test-pull-request/7033/ |
@@ -979,7 +976,7 @@ function lookupAndConnect(self, options) { | |||
var localAddress = options.localAddress; | |||
var localPort = options.localPort; | |||
|
|||
if (localAddress && !exports.isIP(localAddress)) | |||
if (localAddress && !cares.isIP(localAddress)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making isIP
available as a variable would help simplify here and in module.exports
.
Landed in 3745a4d. |
Refactor net module to use the more efficient module.exports = {} pattern. Also renames internal "connect" function to "internalConnect" to avoid collision with exported "connect". PR-URL: #11698 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Refactor net module to use the more efficient module.exports = {} pattern. Also renames internal "connect" function to "internalConnect" to avoid collision with exported "connect". PR-URL: #11698 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
should this be backported? |
Refactor net module to use the more efficient
module.exports = {} pattern.
Also renames internal "connect" function to "internalConnect"
to avoid collision with exported "connect".
See #11611
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
net