From db09275f8e353e257c89e12fed754236b15cee74 Mon Sep 17 00:00:00 2001 From: Alexandre Strzelewicz Date: Wed, 30 May 2018 14:46:06 +0200 Subject: [PATCH] fix: deprecated warning on isbinaryfile --- lib/tools/isbinaryfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tools/isbinaryfile.js b/lib/tools/isbinaryfile.js index 65f37fdf6..7b0135d08 100644 --- a/lib/tools/isbinaryfile.js +++ b/lib/tools/isbinaryfile.js @@ -18,7 +18,7 @@ module.exports = function(bytes, size) { } var descriptor = fs.openSync(file, 'r'); try { - bytes = new Buffer(max_bytes); + bytes = Buffer.alloc(max_bytes); size = fs.readSync(descriptor, bytes, 0, bytes.length, 0); } finally { fs.closeSync(descriptor); @@ -32,7 +32,7 @@ module.exports = function(bytes, size) { fs.open(file, 'r', function(err, descriptor){ if (err) return callback(err); - var bytes = new Buffer(max_bytes); + var bytes = Buffer.alloc(max_bytes); // Read the file with no encoding for raw buffer access. fs.read(descriptor, bytes, 0, bytes.length, 0, function(err, size, bytes){ fs.close(descriptor, function(err2){