Skip to content

Commit

Permalink
debugger: use arrow function for lexical this
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
originalfoo authored and MylesBorins committed Oct 26, 2016
1 parent 3003131 commit 2b93333
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/_debug_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ function Agent() {
this.binding = process._debugAPI;
assert(this.binding, 'Debugger agent running without bindings!');

var self = this;
this.binding.onmessage = function(msg) {
self.clients.forEach(function(client) {
this.binding.onmessage = (msg) => {
this.clients.forEach((client) => {
client.send({}, msg);
});
};
Expand All @@ -67,11 +66,10 @@ Agent.prototype.onConnection = function onConnection(socket) {
c.start();
this.clients.push(c);

var self = this;
c.once('close', function() {
var index = self.clients.indexOf(c);
c.once('close', () => {
var index = this.clients.indexOf(c);
assert(index !== -1);
self.clients.splice(index, 1);
this.clients.splice(index, 1);
});
};

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

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

var self = this;
this.socket.on('close', function() {
self.destroy();
this.socket.on('close', () => {
this.destroy();
});
}
util.inherits(Client, Transform);
Expand Down

0 comments on commit 2b93333

Please sign in to comment.