debugger: use arrow function for lexical this

Refs: https://github.com/nodejs/node/issues/7414
PR-URL: https://github.com/nodejs/node/pull/7415
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
This commit is contained in:
Guy Fraser 2016-06-25 02:11:17 +01:00 committed by James M Snell
parent ae0334a7e7
commit a9387db867

View File

@ -51,9 +51,8 @@ function Agent() {
this.binding = process._debugAPI; this.binding = process._debugAPI;
assert(this.binding, 'Debugger agent running without bindings!'); assert(this.binding, 'Debugger agent running without bindings!');
var self = this; this.binding.onmessage = (msg) => {
this.binding.onmessage = function(msg) { this.clients.forEach((client) => {
self.clients.forEach(function(client) {
client.send({}, msg); client.send({}, msg);
}); });
}; };
@ -68,11 +67,10 @@ Agent.prototype.onConnection = function onConnection(socket) {
c.start(); c.start();
this.clients.push(c); this.clients.push(c);
var self = this; c.once('close', () => {
c.once('close', function() { var index = this.clients.indexOf(c);
var index = self.clients.indexOf(c);
assert(index !== -1); assert(index !== -1);
self.clients.splice(index, 1); this.clients.splice(index, 1);
}); });
}; };
@ -99,9 +97,8 @@ function Client(agent, socket) {
this.on('data', this.onCommand); this.on('data', this.onCommand);
var self = this; this.socket.on('close', () => {
this.socket.on('close', function() { this.destroy();
self.destroy();
}); });
} }
util.inherits(Client, Transform); util.inherits(Client, Transform);