Skip to content

Commit

Permalink
Fix README sample
Browse files Browse the repository at this point in the history
  • Loading branch information
gjtorikian committed Nov 16, 2016
1 parent b327914 commit 74aac0c
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions README.md
Expand Up @@ -52,23 +52,24 @@ Returns a `boolean` of `true` or `false`, depending on if the file is binary.
```javascript
var isBinaryFile = require("isbinaryfile");

if (isBinaryFile(process.argv[2]))
console.log("It is!")
else
console.log("No.")

fs.readFile(process.argv[2], function(err, data) {
fs.lstat(process.argv[2], function(err, stat) {
if (isBinaryFile(data, stat.size))
console.log("It is!")
else
console.log("No.")
fs.readFile("some_file", function(err, data) {
fs.lstat("some_file", function(err, stat) {
isBinaryFile(data, stat.size, function (err, result) {
if (!err) {
if (result) {
console.log("It is!")
}
else {
console.log("No.")
}
}
});
});
});

isBinaryFile.sync(process.argv[2]); // true or false
var stat = fs.lstatSync(process.argv[2]);
isBinaryFile.sync(process.argv[2], stat.size); // true or false
isBinaryFile.sync("some_file"); // true or false
var stat = fs.lstatSync("some_file");
isBinaryFile.sync("some_file", stat.size); // true or false
```

## Testing
Expand Down

0 comments on commit 74aac0c

Please sign in to comment.