Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f3f19ee
net: refactor self=this to arrow functions
benjamingr Mar 23, 2016
0a13099
etw: add event messages
joaocgreis Mar 21, 2016
f14d71c
test: stdin is not always a net.Socket
Fishrock123 Mar 28, 2016
4f1fa2a
test: fix offending max-len linter error
thefourtheye Mar 31, 2016
96bb315
test: ensure _handle property existence
Trott Mar 26, 2016
c6ac6f2
http: Corrects IPv6 address in Host header
mpotra Feb 19, 2016
3f75751
build: introduce ci targets for lint/benchmark
jbergstroem Mar 27, 2016
a40b0cb
test: refactor http-end-throw-socket-handling
santigimeno Mar 12, 2016
8bec8aa
doc: consolidate timers docs in timers.markdown
bengl Mar 21, 2016
0ae5d02
doc: clarify that __dirname is module local
jasnell Apr 2, 2016
7337ef6
doc: minor argument formatting in stream.markdown
jasnell Apr 2, 2016
7491fdc
tools: remove disabling of already-disabled rule
Trott Apr 2, 2016
ce17371
doc: add 'Command Line Options' to 'View on single page'
firedfox Apr 2, 2016
f12c386
doc: clarify stdout/stderr arguments to callback
jasnell Apr 2, 2016
f879f5e
doc: document unspecified behavior for buf.write* methods
jasnell Mar 27, 2016
6052ced
test: fix error message checks in test-module-loading
jasnell Apr 1, 2016
0127c2b
test: fix test-dns.js flakiness
Trott Apr 1, 2016
dd25984
doc: note assert.throws() pitfall
Trott Apr 3, 2016
2ab1237
test: fix flaky test-net-socket-timeout-unref
Trott Mar 29, 2016
aa9fb03
doc: use HTTPS for links where possible
Trott Apr 2, 2016
1c40079
path: fix win32.isAbsolute() inconsistency
mscdex Apr 3, 2016
02f2ebd
test: explicitly set global in test-repl
Trott Apr 3, 2016
7db7a82
test: make arch available in status files
santigimeno Apr 1, 2016
cc8fcc5
test: be explicit about polluting of `global`
Trott Apr 2, 2016
059b607
test: make use of globals explicit
Trott Apr 2, 2016
0f5a51a
assert: Check typed array view type in deepEqual
addaleax Mar 26, 2016
50a062e
tools: remove obsolete lint config file
Trott Mar 30, 2016
8317778
meta: add "joining a wg" section to WORKING_GROUPS.md
mcollina Feb 29, 2016
781290b
doc: refine child_process detach behaviour
eljefedelrodeodeljefe Feb 19, 2016
5c4a414
2016-04-05, Version 5.10.1 (Stable) Release
Apr 5, 2016
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
Next Next commit
net: refactor self=this to arrow functions
Refactor unused self=this code to code without without this pattern
making it more consistent with the rest of our code.

PR-URL: #5857
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Klauke <romankl@users.noreply.github.com>
  • Loading branch information
benjamingr authored and Myles Borins committed Apr 5, 2016
commit f3f19ee5e23801a0b9f1cd678f3ffe0de9eb759a
30 changes: 13 additions & 17 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,7 @@ Socket.prototype.destroySoon = function() {
Socket.prototype._destroy = function(exception, cb) {
debug('destroy');

var self = this;

function fireErrorCallbacks() {
function fireErrorCallbacks(self) {
if (cb) cb(exception);
if (exception && !self._writableState.errorEmitted) {
process.nextTick(emitErrorNT, self, exception);
Expand All @@ -456,11 +454,11 @@ Socket.prototype._destroy = function(exception, cb) {

if (this.destroyed) {
debug('already destroyed, fire error callbacks');
fireErrorCallbacks();
fireErrorCallbacks(this);
return;
}

self._connecting = false;
this._connecting = false;

this.readable = this.writable = false;

Expand All @@ -472,9 +470,9 @@ Socket.prototype._destroy = function(exception, cb) {
if (this !== process.stderr)
debug('close handle');
var isException = exception ? true : false;
this._handle.close(function() {
this._handle.close(() => {
debug('emit close');
self.emit('close', isException);
this.emit('close', isException);
});
this._handle.onread = noop;
this._handle = null;
Expand All @@ -485,7 +483,7 @@ Socket.prototype._destroy = function(exception, cb) {
// to make it re-entrance safe in case Socket.prototype.destroy()
// is called within callbacks
this.destroyed = true;
fireErrorCallbacks();
fireErrorCallbacks(this);

if (this._server) {
COUNTER_NET_SERVER_CONNECTION_CLOSE(this);
Expand Down Expand Up @@ -1078,33 +1076,31 @@ function Server(options, connectionListener) {

EventEmitter.call(this);

var self = this;

if (typeof options === 'function') {
connectionListener = options;
options = {};
self.on('connection', connectionListener);
this.on('connection', connectionListener);
} else {
options = options || {};

if (typeof connectionListener === 'function') {
self.on('connection', connectionListener);
this.on('connection', connectionListener);
}
}

this._connections = 0;

Object.defineProperty(this, 'connections', {
get: internalUtil.deprecate(function() {
get: internalUtil.deprecate(() => {

if (self._usingSlaves) {
if (this._usingSlaves) {
return null;
}
return self._connections;
return this._connections;
}, 'Server.connections property is deprecated. ' +
'Use Server.getConnections method instead.'),
set: internalUtil.deprecate(function(val) {
return (self._connections = val);
set: internalUtil.deprecate((val) => {
return (this._connections = val);
}, 'Server.connections property is deprecated.'),
configurable: true, enumerable: false
});
Expand Down