From db57137928833606ae77d32be261c90c9c1425e1 Mon Sep 17 00:00:00 2001 From: horihiro Date: Sat, 24 Nov 2018 16:55:56 +0900 Subject: [PATCH 1/2] lib: convert to arrow function --- lib/internal/child_process.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 2f19f28b591cd5..b10331ac69f879 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -68,11 +68,11 @@ const handleConversion = { 'net.Native': { simultaneousAccepts: true, - send: function(message, handle, options) { + send: (message, handle, options) => { return handle; }, - got: function(message, handle, emit) { + got: (message, handle, emit) => { emit(handle); } }, @@ -80,13 +80,13 @@ const handleConversion = { 'net.Server': { simultaneousAccepts: true, - send: function(message, server, options) { + send: (message, server, options) => { return server._handle; }, - got: function(message, handle, emit) { + got: (message, handle, emit) => { var server = new net.Server(); - server.listen(handle, function() { + server.listen(handle, () => { emit(server); }); } @@ -141,7 +141,7 @@ const handleConversion = { return handle; }, - postSend: function(message, handle, options, callback, target) { + postSend: (message, handle, options, callback, target) => { // Store the handle after successfully sending it, so it can be closed // when the NODE_HANDLE_ACK is received. If the handle could not be sent, // just close it. @@ -183,11 +183,11 @@ const handleConversion = { 'dgram.Native': { simultaneousAccepts: false, - send: function(message, handle, options) { + send: (message, handle, options) => { return handle; }, - got: function(message, handle, emit) { + got: (message, handle, emit) => { emit(handle); } }, @@ -195,16 +195,16 @@ const handleConversion = { 'dgram.Socket': { simultaneousAccepts: false, - send: function(message, socket, options) { + send: (message, socket, options) => { message.dgramType = socket.type; return socket[kStateSymbol].handle; }, - got: function(message, handle, emit) { + got: (message, handle, emit) => { var socket = new dgram.Socket(message.dgramType); - socket.bind(handle, function() { + socket.bind(handle, () => { emit(socket); }); } @@ -617,7 +617,7 @@ function setupChannel(target, channel) { } // Convert handle object - obj.got.call(this, message, handle, function(handle) { + obj.got.call(this, message, handle, (handle) => { handleMessage(message.msg, handle, isInternal(message.msg)); }); }); @@ -739,7 +739,7 @@ function setupChannel(target, channel) { } if (wasAsyncWrite) { - req.oncomplete = function() { + req.oncomplete = () => { control.unref(); if (typeof callback === 'function') callback(null); @@ -876,7 +876,7 @@ function _validateStdio(stdio, sync) { // Translate stdio into C++-readable form // (i.e. PipeWraps or fds) - stdio = stdio.reduce(function(acc, stdio, i) { + stdio = stdio.reduce((acc, stdio, i) => { function cleanup() { for (var i = 0; i < acc.length; i++) { if ((acc[i].type === 'pipe' || acc[i].type === 'ipc') && acc[i].handle) From ce29aca3293c8a8af05eb83beef576063b8dace7 Mon Sep 17 00:00:00 2001 From: horihiro Date: Sun, 25 Nov 2018 08:52:23 +0900 Subject: [PATCH 2/2] lib: change function declaration in hash object --- lib/internal/child_process.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index b10331ac69f879..3d4a2b5478124a 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -68,11 +68,11 @@ const handleConversion = { 'net.Native': { simultaneousAccepts: true, - send: (message, handle, options) => { + send(message, handle, options) { return handle; }, - got: (message, handle, emit) => { + got(message, handle, emit) { emit(handle); } }, @@ -80,11 +80,11 @@ const handleConversion = { 'net.Server': { simultaneousAccepts: true, - send: (message, server, options) => { + send(message, server, options) { return server._handle; }, - got: (message, handle, emit) => { + got(message, handle, emit) { var server = new net.Server(); server.listen(handle, () => { emit(server); @@ -93,7 +93,7 @@ const handleConversion = { }, 'net.Socket': { - send: function(message, socket, options) { + send(message, socket, options) { if (!socket._handle) return; @@ -141,7 +141,7 @@ const handleConversion = { return handle; }, - postSend: (message, handle, options, callback, target) => { + postSend(message, handle, options, callback, target) { // Store the handle after successfully sending it, so it can be closed // when the NODE_HANDLE_ACK is received. If the handle could not be sent, // just close it. @@ -159,7 +159,7 @@ const handleConversion = { } }, - got: function(message, handle, emit) { + got(message, handle, emit) { var socket = new net.Socket({ handle: handle, readable: true, @@ -183,11 +183,11 @@ const handleConversion = { 'dgram.Native': { simultaneousAccepts: false, - send: (message, handle, options) => { + send(message, handle, options) { return handle; }, - got: (message, handle, emit) => { + got(message, handle, emit) { emit(handle); } }, @@ -195,13 +195,13 @@ const handleConversion = { 'dgram.Socket': { simultaneousAccepts: false, - send: (message, socket, options) => { + send(message, socket, options) { message.dgramType = socket.type; return socket[kStateSymbol].handle; }, - got: (message, handle, emit) => { + got(message, handle, emit) { var socket = new dgram.Socket(message.dgramType); socket.bind(handle, () => {