Merge pull request #17 from aduh95/patch-1
Use Buffer.allocUnsafe instead of deprecated Buffer API
This commit is contained in:
commit
caa7f9964d
4
index.js
4
index.js
|
@ -97,7 +97,7 @@ module.exports.detectFile = function(filepath, opts, cb) {
|
||||||
|
|
||||||
if (opts && opts.sampleSize) {
|
if (opts && opts.sampleSize) {
|
||||||
fd = fs.openSync(filepath, 'r'),
|
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) {
|
fs.read(fd, sample, 0, opts.sampleSize, null, function(err) {
|
||||||
handler(err, sample);
|
handler(err, sample);
|
||||||
|
@ -111,7 +111,7 @@ module.exports.detectFile = function(filepath, opts, cb) {
|
||||||
module.exports.detectFileSync = function(filepath, opts) {
|
module.exports.detectFileSync = function(filepath, opts) {
|
||||||
if (opts && opts.sampleSize) {
|
if (opts && opts.sampleSize) {
|
||||||
var fd = fs.openSync(filepath, 'r'),
|
var fd = fs.openSync(filepath, 'r'),
|
||||||
sample = new Buffer(opts.sampleSize);
|
sample = Buffer.allocUnsafe(opts.sampleSize);
|
||||||
|
|
||||||
fs.readSync(fd, sample, 0, opts.sampleSize);
|
fs.readSync(fd, sample, 0, opts.sampleSize);
|
||||||
fs.closeSync(fd);
|
fs.closeSync(fd);
|
||||||
|
|
Loading…
Reference in New Issue