From bacf500d50447af34fd804a4d63a8d1c55c94b97 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Wed, 13 Jun 2018 11:22:17 +0100 Subject: [PATCH] Avoid deprecated new Buffer() usage See https://alexatnet.com/node-js-10-important-changes/#buffer-1 > Uses of new Buffer() and Buffer() outside of the node_modules directory will now emit a runtime deprecation warning. More details: https://nodejs.org/api/buffer.html#buffer_buffer_from_buffer_alloc_and_buffer_allocunsafe --- core/modules/utils/filesystem.js | 2 +- core/modules/utils/utils.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/modules/utils/filesystem.js b/core/modules/utils/filesystem.js index 7ffe07ee7..57e916108 100644 --- a/core/modules/utils/filesystem.js +++ b/core/modules/utils/filesystem.js @@ -57,7 +57,7 @@ var FILE_BUFFER_LENGTH = 64 * 1024, exports.copyFile = function(srcPath,dstPath) { // Create buffer if required if(!fileBuffer) { - fileBuffer = new Buffer(FILE_BUFFER_LENGTH); + fileBuffer = Buffer.alloc(FILE_BUFFER_LENGTH); } // Create any directories in the destination $tw.utils.createDirectory(path.dirname(dstPath)); diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index 391cdd961..2c06cd5c3 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -712,7 +712,7 @@ exports.base64Decode = function(string64) { // TODO throw "$tw.utils.base64Decode() doesn't work in the browser"; } else { - return (new Buffer(string64,"base64")).toString(); + return Buffer.from(string64,"base64").toString(); } };