isbinaryfile
Advanced tools
Comparing version 0.1.7 to 0.1.8
@@ -16,6 +16,2 @@ var fs = require('fs'); | ||
// NULL byte--it's binary! | ||
if (/\0/.test(bytes)) | ||
return true; | ||
var suspicious_bytes = 0; | ||
@@ -30,3 +26,6 @@ var total_bytes = size > 512 ? 512 : size; | ||
for (var i = 0; i < total_bytes; i++) { | ||
if ((bytes[i] < 7 || bytes[i] > 14) && (bytes[i] < 32 || bytes[i] > 127)) { | ||
if (bytes[i] == 0) { // NULL byte--it's binary! | ||
return true; | ||
} | ||
else if ((bytes[i] < 7 || bytes[i] > 14) && (bytes[i] < 32 || bytes[i] > 127)) { | ||
// UTF-8 detection | ||
@@ -33,0 +32,0 @@ if (bytes[i] > 191 && bytes[i] < 224 && i + 1 < total_bytes) { |
{ | ||
"name": "isbinaryfile", | ||
"version" : "0.1.7", | ||
"version" : "0.1.8", | ||
"description": "Detects if a file is binary in Node.js. Similar to Perl's -B.", | ||
@@ -5,0 +5,0 @@ "main" : "./lib/panino.js", |
79823