From 1538ba9373ba3af7d9f2c9899f0d5516f716c9da Mon Sep 17 00:00:00 2001 From: tpanthera Date: Sat, 17 Nov 2018 18:46:19 +0530 Subject: [PATCH 1/3] src: replace anonymous closure functions with arrow functions --- test/parallel/test-http-localaddress.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index 6763fae1265ac3..6e3bce6b9afec6 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -28,18 +28,18 @@ if (!common.hasMultiLocalhost()) const http = require('http'); const assert = require('assert'); -const server = http.createServer(function(req, res) { +const server = http.createServer((req, res) => { console.log(`Connect from: ${req.connection.remoteAddress}`); assert.strictEqual(req.connection.remoteAddress, '127.0.0.2'); - req.on('end', function() { + req.on('end', () => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end(`You are from: ${req.connection.remoteAddress}`); }); req.resume(); }); -server.listen(0, '127.0.0.1', function() { +server.listen(0, '127.0.0.1', () => { const options = { host: 'localhost', port: this.address().port, path: '/', @@ -47,7 +47,7 @@ server.listen(0, '127.0.0.1', function() { localAddress: '127.0.0.2' }; const req = http.request(options, function(res) { - res.on('end', function() { + res.on('end', () => { server.close(); process.exit(); }); From c5195428bc685dc790e2dd12a21d7d0965a64687 Mon Sep 17 00:00:00 2001 From: Refael Ackermann Date: Fri, 23 Nov 2018 15:23:22 +0530 Subject: [PATCH 2/3] Update test/parallel/test-http-localaddress.js Co-Authored-By: tpanthera --- test/parallel/test-http-localaddress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index 6e3bce6b9afec6..ccd246c48329b0 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -41,7 +41,7 @@ const server = http.createServer((req, res) => { server.listen(0, '127.0.0.1', () => { const options = { host: 'localhost', - port: this.address().port, + port: server.address().port, path: '/', method: 'GET', localAddress: '127.0.0.2' }; From f395b099221fdfc883d4ede18d8f33bcb47f2aae Mon Sep 17 00:00:00 2001 From: tpanthera Date: Fri, 23 Nov 2018 17:46:21 +0530 Subject: [PATCH 3/3] Update test-http-localaddress.js * Revised code alignment. --- test/parallel/test-http-localaddress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index ccd246c48329b0..47af784e9a226e 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -41,7 +41,7 @@ const server = http.createServer((req, res) => { server.listen(0, '127.0.0.1', () => { const options = { host: 'localhost', - port: server.address().port, + port: server.address().port, path: '/', method: 'GET', localAddress: '127.0.0.2' };