test: use Buffer.alloc

Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/8748
This commit is contained in:
Eugene Ostroukhov authored and Jeremiah Senkpiel committed 2016-10-11 12:30:22 -04:00
1 parent 3aec6a68bf
commit b2aea505df
1 file changed
+3 -3
+3 -3
View File
@@ -90,13 +90,13 @@ function checkHttpResponse(port, path, callback) {
}
function makeBufferingDataCallback(dataCallback) {
let buffer = new Buffer(0);
let buffer = Buffer.alloc(0);
return (data) => {
const newData = Buffer.concat([buffer, data]);
const str = newData.toString('utf8');
const lines = str.split('\n');
if (str.endsWith('\n'))
buffer = new Buffer(0);
buffer = Buffer.alloc(0);
else
buffer = Buffer.from(lines.pop(), 'utf8');
for (var line of lines)
@@ -123,7 +123,7 @@ const TestSession = function(socket, harness) {
this.expectedId_ = 1;
this.lastMessageResponseCallback_ = null;
let buffer = new Buffer(0);
let buffer = Buffer.alloc(0);
socket.on('data', (data) => {
buffer = Buffer.concat([buffer, data]);
let consumed;