Chore: replace depracated 'new Buffer' with 'Buffer.from' (#2396)

See [Buffer](https://nodejs.org/docs/latest-v9.x/api/buffer.html) for more details
This commit is contained in:
Yaniv Efraim 2018-04-17 23:49:01 +03:00 committed by Andrey Lushnikov
parent b40e381f65
commit ed4be10ae3
3 changed files with 4 additions and 4 deletions

View File

@ -749,7 +749,7 @@ class Page extends EventEmitter {
if (options.fullPage) if (options.fullPage)
await this.setViewport(this._viewport); await this.setViewport(this._viewport);
const buffer = new Buffer(result.data, 'base64'); const buffer = Buffer.from(result.data, 'base64');
if (options.path) if (options.path)
await writeFileAsync(options.path, buffer); await writeFileAsync(options.path, buffer);
return buffer; return buffer;
@ -801,7 +801,7 @@ class Page extends EventEmitter {
marginRight: marginRight, marginRight: marginRight,
pageRanges: pageRanges pageRanges: pageRanges
}); });
const buffer = new Buffer(result.data, 'base64'); const buffer = Buffer.from(result.data, 'base64');
if (options.path) if (options.path)
await writeFileAsync(options.path, buffer); await writeFileAsync(options.path, buffer);
return buffer; return buffer;

View File

@ -79,7 +79,7 @@ class Tracing {
while (!eof) { while (!eof) {
const response = await this._client.send('IO.read', {handle}); const response = await this._client.send('IO.read', {handle});
eof = response.eof; eof = response.eof;
bufs.push(new Buffer(response.data)); bufs.push(Buffer.from(response.data));
if (path) if (path)
await writeAsync(file, response.data); await writeAsync(file, response.data);
} }

View File

@ -185,7 +185,7 @@ class SimpleServer {
const pathName = url.parse(request.url).path; const pathName = url.parse(request.url).path;
if (this._auths.has(pathName)) { if (this._auths.has(pathName)) {
const auth = this._auths.get(pathName); const auth = this._auths.get(pathName);
const credentials = new Buffer((request.headers.authorization || '').split(' ')[1] || '', 'base64').toString(); const credentials = Buffer.from((request.headers.authorization || '').split(' ')[1] || '', 'base64').toString();
if (credentials !== `${auth.username}:${auth.password}`) { if (credentials !== `${auth.username}:${auth.password}`) {
response.writeHead(401, { 'WWW-Authenticate': 'Basic realm="Secure Area"' }); response.writeHead(401, { 'WWW-Authenticate': 'Basic realm="Secure Area"' });
response.end('HTTP Error 401 Unauthorized: Access is denied'); response.end('HTTP Error 401 Unauthorized: Access is denied');