Remove deprecated Buffer constructor usage

Fixes #1709
This commit is contained in:
Nick O'Leary
2018-10-24 13:45:34 +01:00
parent 7dcca2c907
commit e4d518749f
13 changed files with 26 additions and 26 deletions

View File

@@ -506,7 +506,7 @@ describe('debug node', function() {
helper.load(debugNode, flow, function() {
var n1 = helper.getNode("n1");
websocket_test(function() {
n1.emit("input", {payload: new Buffer.from('HELLO', 'utf8')});
n1.emit("input", {payload: Buffer.from('HELLO', 'utf8')});
}, function(msg) {
JSON.parse(msg).should.eql([{
topic:"debug",

View File

@@ -177,7 +177,7 @@ describe('exec node', function() {
function(arg1, arg2, arg3, arg4) {
//console.log(arg1);
// arg3(error,stdout,stderr);
arg3("error",new Buffer([0x01,0x02,0x03,0x88]),new Buffer([0x01,0x02,0x03,0x88]));
arg3("error",Buffer.from([0x01,0x02,0x03,0x88]),Buffer.from([0x01,0x02,0x03,0x88]));
});
helper.load(execNode, flow, function() {
var n1 = helper.getNode("n1");
@@ -595,7 +595,7 @@ describe('exec node', function() {
}
catch(err) { done(err); }
});
n1.receive({payload:new Buffer([0x01,0x02,0x03,0x88])});
n1.receive({payload:Buffer.from([0x01,0x02,0x03,0x88])});
});
});

View File

@@ -251,7 +251,7 @@ describe('function node', function() {
testNonObjectMessage('return "foo"', done)
});
it('should drop and log non-object message types - buffer', function(done) {
testNonObjectMessage('return new Buffer("hello")', done)
testNonObjectMessage('return Buffer.from("hello")', done)
});
it('should drop and log non-object message types - array', function(done) {
testNonObjectMessage('return [[[1,2,3]]]', done)

View File

@@ -390,7 +390,7 @@ describe('HTTP Request Node', function() {
done(err);
}
});
n1.receive({payload:new Buffer('hello'), headers: { 'content-type': 'text/plain'}});
n1.receive({payload:Buffer.from('hello'), headers: { 'content-type': 'text/plain'}});
});
});

View File

@@ -454,7 +454,7 @@ describe('websocket Node', function() {
});
getSocket("n1").on("open", function() {
helper.getNode("n3").send({
payload: new Buffer("hello")
payload: Buffer.from("hello")
});
});
});

View File

@@ -236,7 +236,7 @@ describe('SPLIT node', function() {
done(err);
}
});
var b = new Buffer.from("12345678");
var b = Buffer.from("12345678");
sn1.receive({payload:b});
});
});
@@ -260,8 +260,8 @@ describe('SPLIT node', function() {
done(err);
}
});
var b1 = new Buffer.from("123412");
var b2 = new Buffer.from("341234");
var b1 = Buffer.from("123412");
var b2 = Buffer.from("341234");
sn1.receive({payload:b1});
sn1.receive({payload:b2});
});
@@ -364,7 +364,7 @@ describe('SPLIT node', function() {
if (msg.parts.index === 0) { msg.payload.length.should.equal(2); }
if (msg.parts.index === 1) { msg.payload.length.should.equal(1); done(); }
});
var b = new Buffer.from("123");
var b = Buffer.from("123");
sn1.receive({ payload: b });
});
});
@@ -382,7 +382,7 @@ describe('SPLIT node', function() {
if (msg.parts.index === 0) { msg.payload.length.should.equal(2); }
if (msg.parts.index === 1) { msg.payload.length.should.equal(1); done(); }
});
var b = new Buffer.from("123");
var b = Buffer.from("123");
sn1.receive({ payload: b });
});
});

View File

@@ -127,7 +127,7 @@ describe('JSON node', function() {
},150);
jn1.receive({payload:true});
jn1.receive({payload:1});
jn1.receive({payload:new Buffer("a")});
jn1.receive({payload:Buffer.from("a")});
});
});

View File

@@ -169,7 +169,7 @@ describe('YAML node', function() {
},150);
yn1.receive({payload:true});
yn1.receive({payload:1});
yn1.receive({payload:new Buffer("a")});
yn1.receive({payload:Buffer.from("a")});
});
});

View File

@@ -574,7 +574,7 @@ describe('file Nodes', function() {
}
});
for(var i = 0; i < file_count; i++) {
var data = new Buffer(len);
var data = Buffer.alloc?Buffer.alloc(len):new Buffer(len);
data.fill(i);
var name = path.join(tmp_path, String(i));
var msg = {payload:data, filename:name};
@@ -617,7 +617,7 @@ describe('file Nodes', function() {
}
});
for(var i = 0; i < file_count; i++) {
var data = new Buffer(len);
var data = Buffer.alloc?Buffer.alloc(len):new Buffer(len);
data.fill(i);
var name = path.join(tmp_path, String(i));
var msg = {payload:data, filename:name};