Socket
Socket
Sign inDemoInstall

isbinaryfile

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isbinaryfile - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

tests/fixtures/08_dir/.gitkeep

14

index.js

@@ -8,5 +8,8 @@ var fs = require('fs');

if (size === undefined) {
var file = bytes, existsSync = fs.existsSync || path.existsSync;
if (!existsSync(file))
return false;
var file = bytes;
try {
if(!fs.statSync(file).isFile()) return false;
} catch (err) {
// otherwise continue on
}
var descriptor = fs.openSync(file, 'r');

@@ -23,5 +26,4 @@ try {

var file = bytes, callback = size;
var exists = fs.exists || path.exists;
exists(file, function (exists) {
if (!exists) return callback(null, false);
fs.stat(file, function(err, stat) {
if (err || !stat.isFile()) return callback(null, false);

@@ -28,0 +30,0 @@ fs.open(file, 'r', function(err, descriptor){

{
"name": "isbinaryfile",
"version" : "2.0.2",
"version" : "2.0.3",
"description": "Detects if a file is binary in Node.js. Similar to Perl's -B.",

@@ -5,0 +5,0 @@ "main" : "./lib/panino.js",

@@ -64,2 +64,14 @@ "mocha";

it('should fail a directory', function() {
assert(!isBinaryFile("tests/fixtures/08_dir"));
});
it('should fail a directory with async', function(done) {
isBinaryFile("tests/fixtures/08_dir", function(err, result) {
assert(!err);
assert(!result);
done();
});
});
it('should not fail with async', function(done) {

@@ -66,0 +78,0 @@ assert.doesNotThrow(function() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc