diff --git a/nodes/core/core/75-exec.js b/nodes/core/core/75-exec.js index 53a3d3c48..ef4f7037a 100644 --- a/nodes/core/core/75-exec.js +++ b/nodes/core/core/75-exec.js @@ -86,7 +86,7 @@ module.exports = function(RED) { child.stderr.on('data', function (data) { if (node.activeProcesses.hasOwnProperty(child.pid) && node.activeProcesses[child.pid] !== null) { if (isUtf8(data)) { msg.payload = data.toString(); } - else { msg.payload = new Buffer(data); } + else { msg.payload = new Buffer.from(data); } node.send([null,RED.util.cloneMessage(msg),null]); } }); @@ -121,7 +121,7 @@ module.exports = function(RED) { /* istanbul ignore else */ if (RED.settings.verbose) { node.log(cl); } child = exec(cl, {encoding: 'binary', maxBuffer:10000000}, function (error, stdout, stderr) { - msg.payload = new Buffer(stdout,"binary"); + msg.payload = new Buffer.from(stdout,"binary"); if (isUtf8(msg.payload)) { msg.payload = msg.payload.toString(); } var msg2 = null; if (stderr) { diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 4f836c30f..531e7b43d 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -47,7 +47,7 @@ module.exports = function(RED) { node.status({fill:"grey",shape:"dot",text:"common.status.connecting"}); var id = (1+Math.random()*4294967295).toString(16); client = net.connect(node.port, node.host, function() { - buffer = (node.datatype == 'buffer')? new Buffer(0):""; + buffer = (node.datatype == 'buffer') ? new Buffer.from(0) : ""; node.connected = true; node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port})); node.status({fill:"green",shape:"dot",text:"common.status.connected"}); @@ -132,7 +132,7 @@ module.exports = function(RED) { count++; node.status({text:RED._("tcpin.status.connections",{count:count})}); - var buffer = (node.datatype == 'buffer')? new Buffer(0):""; + var buffer = (node.datatype == 'buffer') ? new Buffer.from(0) : ""; socket.on('data', function (data) { if (node.datatype != 'buffer') { data = data.toString(node.datatype); @@ -269,9 +269,9 @@ module.exports = function(RED) { if (Buffer.isBuffer(msg.payload)) { client.write(msg.payload); } else if (typeof msg.payload === "string" && node.base64) { - client.write(new Buffer(msg.payload,'base64')); + client.write(new Buffer.from(msg.payload,'base64')); } else { - client.write(new Buffer(""+msg.payload)); + client.write(new Buffer.from(""+msg.payload)); } if (node.doend === true) { end = true; @@ -296,9 +296,9 @@ module.exports = function(RED) { if (Buffer.isBuffer(msg.payload)) { client.write(msg.payload); } else if (typeof msg.payload === "string" && node.base64) { - client.write(new Buffer(msg.payload,'base64')); + client.write(new Buffer.from(msg.payload,'base64')); } else { - client.write(new Buffer(""+msg.payload)); + client.write(new Buffer.from(""+msg.payload)); } } } @@ -307,9 +307,9 @@ module.exports = function(RED) { if (Buffer.isBuffer(msg.payload)) { connectionPool[i].write(msg.payload); } else if (typeof msg.payload === "string" && node.base64) { - connectionPool[i].write(new Buffer(msg.payload,'base64')); + connectionPool[i].write(new Buffer.from(msg.payload,'base64')); } else { - connectionPool[i].write(new Buffer(""+msg.payload)); + connectionPool[i].write(new Buffer.from(""+msg.payload)); } } } @@ -346,9 +346,9 @@ module.exports = function(RED) { if (Buffer.isBuffer(msg.payload)) { buffer = msg.payload; } else if (typeof msg.payload === "string" && node.base64) { - buffer = new Buffer(msg.payload,'base64'); + buffer = new Buffer.from(msg.payload,'base64'); } else { - buffer = new Buffer(""+msg.payload); + buffer = new Buffer.from(""+msg.payload); } for (var i = 0; i < connectedSockets.length; i += 1) { if (node.doend === true) { connectedSockets[i].end(buffer); } @@ -431,10 +431,10 @@ module.exports = function(RED) { if (!clients[connection_id].connected) { var buf; if (this.out == "count") { - if (this.splitc === 0) { buf = new Buffer(1); } - else { buf = new Buffer(this.splitc); } + if (this.splitc === 0) { buf = new Buffer.alloc(1); } + else { buf = new Buffer.alloc(this.splitc); } } - else { buf = new Buffer(65536); } // set it to 64k... hopefully big enough for most TCP packets.... but only hopefully + else { buf = new Buffer.alloc(65536); } // set it to 64k... hopefully big enough for most TCP packets.... but only hopefully clients[connection_id].client = net.Socket(); if (socketTimeout !== null) { clients[connection_id].client.setTimeout(socketTimeout);} @@ -484,7 +484,7 @@ module.exports = function(RED) { clients[connection_id].timeout = setTimeout(function () { if (clients[connection_id]) { clients[connection_id].timeout = null; - clients[connection_id].msg.payload = new Buffer(i+1); + clients[connection_id].msg.payload = new Buffer.alloc(i+1); buf.copy(clients[connection_id].msg.payload,0,0,i+1); node.send(clients[connection_id].msg); if (clients[connection_id].client) { @@ -505,7 +505,7 @@ module.exports = function(RED) { i += 1; if ( i >= node.splitc) { if (clients[connection_id]) { - clients[connection_id].msg.payload = new Buffer(i); + clients[connection_id].msg.payload = new Buffer.alloc(i); buf.copy(clients[connection_id].msg.payload,0,0,i); node.send(clients[connection_id].msg); if (clients[connection_id].client) { @@ -523,7 +523,7 @@ module.exports = function(RED) { i += 1; if (data[j] == node.splitc) { if (clients[connection_id]) { - clients[connection_id].msg.payload = new Buffer(i); + clients[connection_id].msg.payload = new Buffer.alloc(i); buf.copy(clients[connection_id].msg.payload,0,0,i); node.send(clients[connection_id].msg); if (clients[connection_id].client) { diff --git a/nodes/core/io/32-udp.js b/nodes/core/io/32-udp.js index 849a7e270..ab810ac4b 100644 --- a/nodes/core/io/32-udp.js +++ b/nodes/core/io/32-udp.js @@ -181,11 +181,11 @@ module.exports = function(RED) { } else { var message; if (node.base64) { - message = new Buffer(msg.payload, 'base64'); + message = new Buffer.from(msg.payload, 'base64'); } else if (msg.payload instanceof Buffer) { message = msg.payload; } else { - message = new Buffer(""+msg.payload); + message = new Buffer.from(""+msg.payload); } sock.send(message, 0, message.length, por, add, function(err, bytes) { if (err) { diff --git a/nodes/core/storage/50-file.js b/nodes/core/storage/50-file.js index 10d5b10a6..987c39d06 100644 --- a/nodes/core/storage/50-file.js +++ b/nodes/core/storage/50-file.js @@ -55,7 +55,7 @@ module.exports = function(RED) { if (typeof data === "boolean") { data = data.toString(); } if (typeof data === "number") { data = data.toString(); } if ((this.appendNewline) && (!Buffer.isBuffer(data))) { data += os.EOL; } - node.data.push(new Buffer(data)); + node.data.push(new Buffer.from(data)); while (node.data.length > 0) { if (this.overwriteFile === "true") {