Antoine du Hamel 2018-07-29 21:01:21 +02:00 committed by GitHub
parent 6ff1aea137
commit 4add1722fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -97,7 +97,7 @@ module.exports.detectFile = function(filepath, opts, cb) {
if (opts && opts.sampleSize) {
fd = fs.openSync(filepath, 'r'),
sample = new Buffer(opts.sampleSize);
sample = Buffer.allocUnsafe(opts.sampleSize);
fs.read(fd, sample, 0, opts.sampleSize, null, function(err) {
handler(err, sample);
@ -111,7 +111,7 @@ module.exports.detectFile = function(filepath, opts, cb) {
module.exports.detectFileSync = function(filepath, opts) {
if (opts && opts.sampleSize) {
var fd = fs.openSync(filepath, 'r'),
sample = new Buffer(opts.sampleSize);
sample = Buffer.allocUnsafe(opts.sampleSize);
fs.readSync(fd, sample, 0, opts.sampleSize);
fs.closeSync(fd);