Skip to content

Commit c406ad8

Browse files
originalfooevanlucas
authored andcommitted
debugger: use arrow function for lexical this
Refs: #7414 PR-URL: #7415 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
1 parent 8eb6e71 commit c406ad8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/_debug_agent.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ function Agent() {
5151
this.binding = process._debugAPI;
5252
assert(this.binding, 'Debugger agent running without bindings!');
5353

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

71-
var self = this;
72-
c.once('close', function() {
73-
var index = self.clients.indexOf(c);
70+
c.once('close', () => {
71+
var index = this.clients.indexOf(c);
7472
assert(index !== -1);
75-
self.clients.splice(index, 1);
73+
this.clients.splice(index, 1);
7674
});
7775
};
7876

@@ -99,9 +97,8 @@ function Client(agent, socket) {
9997

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

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

0 commit comments

Comments
 (0)