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 коммит произвёл James M Snell
Родитель ae0334a7e7
Коммит a9387db867
1 изменённых файлов: 7 добавлений и 10 удалений

Просмотреть файл

@ -51,9 +51,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);
});
};
@ -68,11 +67,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);
});
};
@ -99,9 +97,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);