Gathering detailed insights and metrics for isbinaryfile
Gathering detailed insights and metrics for isbinaryfile
Gathering detailed insights and metrics for isbinaryfile
Gathering detailed insights and metrics for isbinaryfile
Detects if a file is binary in Node.js. Similar to Perl's -B
npm install isbinaryfile
99.3
Supply Chain
89.2
Quality
82.8
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
165 Stars
202 Commits
23 Forks
6 Watching
3 Branches
16 Contributors
Updated on 23 Oct 2024
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-4.7%
1,125,334
Compared to previous day
Last week
2.4%
6,382,643
Compared to previous week
Last month
10.5%
26,842,338
Compared to previous month
Last year
15.6%
277,185,088
Compared to previous year
Detects if a file is binary in Node.js using ✨promises✨. Similar to Perl's -B
switch, in that:
null
byte; if it's found, it's binaryMuch of the logic is pretty much ported from ag.
Note: if the file doesn't exist or is a directory, an error is thrown.
npm install isbinaryfile
Returns Promise<boolean>
(or just boolean
for *Sync
). true
if the file is binary, false
otherwise.
filepath
- a string
indicating the path to the file.bytes
- a Buffer
of the file's contents.size
- an optional number
indicating the file size.filepath
- a string
indicating the path to the file.bytes
- a Buffer
of the file's contents.size
- an optional number
indicating the file size.Here's an arbitrary usage:
1const isBinaryFile = require("isbinaryfile").isBinaryFile; 2const fs = require("fs"); 3 4const filename = "fixtures/pdf.pdf"; 5const data = fs.readFileSync(filename); 6const stat = fs.lstatSync(filename); 7 8isBinaryFile(data, stat.size).then((result) => { 9 if (result) { 10 console.log("It is binary!") 11 } 12 else { 13 console.log("No it is not.") 14 } 15}); 16 17const isBinaryFileSync = require("isbinaryfile").isBinaryFileSync; 18const bytes = fs.readFileSync(filename); 19const size = fs.lstatSync(filename).size; 20console.log(isBinaryFileSync(bytes, size)); // true or false
Run npm install
, then run npm test
.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
2 existing vulnerabilities detected
Details
Reason
6 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 2/10 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More