From 1e9f97bc8fc4ceb4eb5f1f0a18f66e30342c4ceb Mon Sep 17 00:00:00 2001 From: Guy Fraser Date: Sat, 25 Jun 2016 02:11:17 +0100 Subject: [PATCH 1/3] debugger: use arrow function for lexical `this` Refs #7414 --- lib/_debug_agent.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/_debug_agent.js b/lib/_debug_agent.js index cb4684f0eddfac..61983f17c31c96 100644 --- a/lib/_debug_agent.js +++ b/lib/_debug_agent.js @@ -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); }); }; From 23999c7816a15526544b27ea825c82d524cd8696 Mon Sep 17 00:00:00 2001 From: Guy Fraser Date: Sat, 25 Jun 2016 02:12:50 +0100 Subject: [PATCH 2/3] debugger: use arrow function for lexical `this` Refs #7414 --- lib/_debug_agent.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/_debug_agent.js b/lib/_debug_agent.js index 61983f17c31c96..b20a960fdaaece 100644 --- a/lib/_debug_agent.js +++ b/lib/_debug_agent.js @@ -66,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); }); }; From 86548a071232a9b7428af415b721006d1e03d78c Mon Sep 17 00:00:00 2001 From: Guy Fraser Date: Sat, 25 Jun 2016 02:14:22 +0100 Subject: [PATCH 3/3] debugger: use arrow function for lexical `this` Refs #7414 --- lib/_debug_agent.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/_debug_agent.js b/lib/_debug_agent.js index b20a960fdaaece..3457c6db8ac9d6 100644 --- a/lib/_debug_agent.js +++ b/lib/_debug_agent.js @@ -96,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);