Skip to content

Commit 2b93333

Browse files
originalfooMylesBorins
authored andcommitted
debugger: use arrow function for lexical this
Refs: #7414 PR-URL: #7415 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 3003131 commit 2b93333

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/_debug_agent.js

+7-10
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@ function Agent() {
5050
this.binding = process._debugAPI;
5151
assert(this.binding, 'Debugger agent running without bindings!');
5252

53-
var self = this;
54-
this.binding.onmessage = function(msg) {
55-
self.clients.forEach(function(client) {
53+
this.binding.onmessage = (msg) => {
54+
this.clients.forEach((client) => {
5655
client.send({}, msg);
5756
});
5857
};
@@ -67,11 +66,10 @@ Agent.prototype.onConnection = function onConnection(socket) {
6766
c.start();
6867
this.clients.push(c);
6968

70-
var self = this;
71-
c.once('close', function() {
72-
var index = self.clients.indexOf(c);
69+
c.once('close', () => {
70+
var index = this.clients.indexOf(c);
7371
assert(index !== -1);
74-
self.clients.splice(index, 1);
72+
this.clients.splice(index, 1);
7573
});
7674
};
7775

@@ -98,9 +96,8 @@ function Client(agent, socket) {
9896

9997
this.on('data', this.onCommand);
10098

101-
var self = this;
102-
this.socket.on('close', function() {
103-
self.destroy();
99+
this.socket.on('close', () => {
100+
this.destroy();
104101
});
105102
}
106103
util.inherits(Client, Transform);

0 commit comments

Comments
 (0)