Skip to content

Update the 'Buffer' calls, fix the DeprecationWarning #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/webpagetest
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var formatData = function(err, data, info) {
} else if (info) {
encoding = info.encoding;
if (encoding === 'binary') {
data = new Buffer(data, 'binary');
data = new Buffer.from(data, 'binary');
type = info.type;
} else {
data = {type: info.type, data: data};
Expand Down
2 changes: 1 addition & 1 deletion lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function netLogParser(data) {

// Convert image (binary) into data URI (string)
function dataURI(data) {
return new Buffer(data || '', 'binary').toString('base64');
return new Buffer.from(data || '', 'binary').toString('base64');
}

// Convert script objects into formatted string
Expand Down
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function output(callback, err, data, info) {
code = err.code || code;
} else if (info) {
if (info.encoding === 'binary') {
data = new Buffer(data, 'binary');
data = new Buffer.from(data, 'binary');
type = info.type;
} else {
data = {type: info.type, data: data};
Expand Down
2 changes: 1 addition & 1 deletion lib/webpagetest.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function get(config, pathname, proxy, agent, callback, encoding) {

res.on('end', function onEnd() {
var i, len, pos,
buffer = new Buffer(length),
buffer = new Buffer.alloc(length),
type = (res.headers['content-type'] || '').split(';')[0];

for (i = 0, len = data.length, pos = 0; i < len; i += 1) {
Expand Down