Skip to content

net: named anonymous functions #21062

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

Closed
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
42 changes: 21 additions & 21 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ function shutdownSocket(self, callback) {

// the user has called .end(), and all the bytes have been
// sent out to the other side.
Socket.prototype._final = function(cb) {
Copy link
Member

Choose a reason for hiding this comment

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

@ErnestoSalazar Congrats on your first PR in Node.js!
However, everything assigned to prototype should be good (comment) and not required to be named.

Copy link
Contributor Author

@ErnestoSalazar ErnestoSalazar May 31, 2018

Choose a reason for hiding this comment

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

@trivikr So, i see that other files also follows that same convention like https.js, thanks for your fast reply :D

Socket.prototype._final = function _final(cb) {
// If still connecting - defer handling `_final` until 'connect' will happen
if (this.connecting) {
debug('_final: not yet connected');
Expand Down Expand Up @@ -461,7 +461,7 @@ Socket.prototype.setNoDelay = function(enable) {
};


Socket.prototype.setKeepAlive = function(setting, msecs) {
Socket.prototype.setKeepAlive = function setKeepAlive(setting, msecs) {
if (!this._handle) {
this.once('connect', () => this.setKeepAlive(setting, msecs));
return this;
Expand All @@ -474,7 +474,7 @@ Socket.prototype.setKeepAlive = function(setting, msecs) {
};


Socket.prototype.address = function() {
Socket.prototype.address = function address() {
return this._getsockname();
};

Expand Down Expand Up @@ -513,7 +513,7 @@ Object.defineProperty(Socket.prototype, 'bufferSize', {


// Just call handle.readStart until we have enough in the buffer
Socket.prototype._read = function(n) {
Socket.prototype._read = function _read(n) {
debug('_read');

if (this.connecting || !this._handle) {
Expand All @@ -530,7 +530,7 @@ Socket.prototype._read = function(n) {
};


Socket.prototype.end = function(data, encoding, callback) {
Socket.prototype.end = function end(data, encoding, callback) {
stream.Duplex.prototype.end.call(this, data, encoding, callback);
DTRACE_NET_STREAM_END(this);
return this;
Expand Down Expand Up @@ -560,7 +560,7 @@ function maybeDestroy(socket) {
}


Socket.prototype.destroySoon = function() {
Socket.prototype.destroySoon = function destroySoon() {
if (this.writable)
this.end();

Expand All @@ -571,7 +571,7 @@ Socket.prototype.destroySoon = function() {
};


Socket.prototype._destroy = function(exception, cb) {
Socket.prototype._destroy = function _destroy(exception, cb) {
debug('destroy');

this.connecting = false;
Expand Down Expand Up @@ -667,7 +667,7 @@ function onread(nread, buffer) {
}


Socket.prototype._getpeername = function() {
Socket.prototype._getpeername = function _getpeername() {
if (!this._peername) {
if (!this._handle || !this._handle.getpeername) {
return {};
Expand Down Expand Up @@ -705,7 +705,7 @@ protoGetter('remotePort', function remotePort() {
});


Socket.prototype._getsockname = function() {
Socket.prototype._getsockname = function _getsockname() {
if (!this._handle || !this._handle.getsockname) {
return {};
}
Expand Down Expand Up @@ -761,12 +761,12 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
};


Socket.prototype._writev = function(chunks, cb) {
Socket.prototype._writev = function _writev(chunks, cb) {
this._writeGeneric(true, chunks, '', cb);
};


Socket.prototype._write = function(data, encoding, cb) {
Socket.prototype._write = function _write(data, encoding, cb) {
this._writeGeneric(false, data, encoding, cb);
};

Expand Down Expand Up @@ -932,7 +932,7 @@ function internalConnect(
}


Socket.prototype.connect = function(...args) {
Socket.prototype.connect = function connect(...args) {
let normalized;
// If passed an array, it's treated as an array of arguments that have
// already been normalized (so we don't normalize more than once). This has
Expand Down Expand Up @@ -1093,7 +1093,7 @@ function connectErrorNT(self, err) {
}


Socket.prototype.ref = function() {
Socket.prototype.ref = function ref() {
if (!this._handle) {
this.once('connect', this.ref);
return this;
Expand All @@ -1107,7 +1107,7 @@ Socket.prototype.ref = function() {
};


Socket.prototype.unref = function() {
Socket.prototype.unref = function unref() {
if (!this._handle) {
this.once('connect', this.unref);
return this;
Expand Down Expand Up @@ -1407,7 +1407,7 @@ function listenInCluster(server, address, port, addressType,
}


Server.prototype.listen = function(...args) {
Server.prototype.listen = function listen(...args) {
var normalized = normalizeArgs(args);
var options = normalized[0];
var cb = normalized[1];
Expand Down Expand Up @@ -1515,7 +1515,7 @@ Object.defineProperty(Server.prototype, 'listening', {
enumerable: true
});

Server.prototype.address = function() {
Server.prototype.address = function address() {
if (this._handle && this._handle.getsockname) {
var out = {};
var err = this._handle.getsockname(out);
Expand Down Expand Up @@ -1564,7 +1564,7 @@ function onconnection(err, clientHandle) {
}


Server.prototype.getConnections = function(cb) {
Server.prototype.getConnections = function getConnections(cb) {
const self = this;

function end(err, connections) {
Expand Down Expand Up @@ -1602,7 +1602,7 @@ Server.prototype.getConnections = function(cb) {
};


Server.prototype.close = function(cb) {
Server.prototype.close = function close(cb) {
if (typeof cb === 'function') {
if (!this._handle) {
this.once('close', function close() {
Expand Down Expand Up @@ -1641,7 +1641,7 @@ Server.prototype.close = function(cb) {
return this;
};

Server.prototype._emitCloseIfDrained = function() {
Server.prototype._emitCloseIfDrained = function _emitCloseIfDrained() {
debug('SERVER _emitCloseIfDrained');

if (this._handle || this._connections) {
Expand Down Expand Up @@ -1677,7 +1677,7 @@ Server.prototype._setupWorker = function(socketList) {
});
};

Server.prototype.ref = function() {
Server.prototype.ref = function ref() {
this._unref = false;

if (this._handle)
Expand All @@ -1686,7 +1686,7 @@ Server.prototype.ref = function() {
return this;
};

Server.prototype.unref = function() {
Server.prototype.unref = function unref() {
this._unref = true;

if (this._handle)
Expand Down