Skip to content

Commit

Permalink
fix: deprecated warning on isbinaryfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Unitech committed May 30, 2018
1 parent 99cd385 commit db09275
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/tools/isbinaryfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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){
Expand Down

0 comments on commit db09275

Please sign in to comment.