Skip to content

Commit

Permalink
Use Buffer.allocUnsafe instead of deprecated Buffer API
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Jul 29, 2018
1 parent 6ff1aea commit 4add172
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 4add172

Please sign in to comment.