isbinaryfile
Advanced tools
Comparing version 0.1.0 to 0.1.1
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()); | ||
``` |
2281
34