Merge pull request #17 from aduh95/patch-1

Use Buffer.allocUnsafe instead of deprecated Buffer API
This commit is contained in:
Dmitry Shirokov 2018-08-18 08:52:20 +10:00 committed by GitHub
commit caa7f9964d
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);