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 0.1.0 to 0.1.1

4

index.js
var fs = require('fs');
module.exports = function(file) {
module.exports = function(file, statSize) {
// Read the file with no encoding for raw buffer access.
var bytes = fs.readFileSync(file);
var size = fs.statSync(file).size;
var size = statSize || fs.statSync(file).size;
var suspicious_bytes = 0;

@@ -8,0 +8,0 @@ var total_bytes = size > 1024 ? 1024 : size;

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

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

@@ -29,2 +29,7 @@ isBinaryFile

Ta da.
Ta da. If you've already `stat()`-ed a file, you can pass the stat's `size` info in to save time:
```javascript
var stat = lstatSync(process.argv[2])
var isBF = isBinaryFile(process.argv[2], stat.size());
```
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