From ed4be10ae317de0ddc16f00c9f22e963028634d7 Mon Sep 17 00:00:00 2001 From: Yaniv Efraim Date: Tue, 17 Apr 2018 23:49:01 +0300 Subject: [PATCH] Chore: replace depracated 'new Buffer' with 'Buffer.from' (#2396) See [Buffer](https://nodejs.org/docs/latest-v9.x/api/buffer.html) for more details --- lib/Page.js | 4 ++-- lib/Tracing.js | 2 +- test/server/SimpleServer.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Page.js b/lib/Page.js index 632390b4..fee34258 100644 --- a/lib/Page.js +++ b/lib/Page.js @@ -749,7 +749,7 @@ class Page extends EventEmitter { if (options.fullPage) await this.setViewport(this._viewport); - const buffer = new Buffer(result.data, 'base64'); + const buffer = Buffer.from(result.data, 'base64'); if (options.path) await writeFileAsync(options.path, buffer); return buffer; @@ -801,7 +801,7 @@ class Page extends EventEmitter { marginRight: marginRight, pageRanges: pageRanges }); - const buffer = new Buffer(result.data, 'base64'); + const buffer = Buffer.from(result.data, 'base64'); if (options.path) await writeFileAsync(options.path, buffer); return buffer; diff --git a/lib/Tracing.js b/lib/Tracing.js index 1bce240b..d2737fba 100644 --- a/lib/Tracing.js +++ b/lib/Tracing.js @@ -79,7 +79,7 @@ class Tracing { while (!eof) { const response = await this._client.send('IO.read', {handle}); eof = response.eof; - bufs.push(new Buffer(response.data)); + bufs.push(Buffer.from(response.data)); if (path) await writeAsync(file, response.data); } diff --git a/test/server/SimpleServer.js b/test/server/SimpleServer.js index bbd14538..9825d69d 100644 --- a/test/server/SimpleServer.js +++ b/test/server/SimpleServer.js @@ -185,7 +185,7 @@ class SimpleServer { const pathName = url.parse(request.url).path; if (this._auths.has(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}`) { response.writeHead(401, { 'WWW-Authenticate': 'Basic realm="Secure Area"' }); response.end('HTTP Error 401 Unauthorized: Access is denied');