Gathering detailed insights and metrics for istextorbinary-ilkkah
Gathering detailed insights and metrics for istextorbinary-ilkkah
npm install istextorbinary-ilkkah
Typescript
Module System
Min. Node Version
Node Version
NPM Version
72.8
Supply Chain
99.4
Quality
75.3
Maintenance
100
Vulnerability
100
License
TypeScript (95.82%)
JavaScript (4.18%)
Total Downloads
509
Last Day
2
Last Week
11
Last Month
27
Last Year
319
150 Stars
157 Commits
17 Forks
4 Watching
2 Branches
7 Contributors
Minified
Minified + Gzipped
Latest Version
6.0.1
Package Id
istextorbinary-ilkkah@6.0.1
Unpacked Size
58.68 kB
Size
10.76 kB
File Count
12
NPM Version
9.8.0
Node Version
20.5.1
Publised On
21 Aug 2023
Cumulative downloads
Total Downloads
Last day
100%
2
Compared to previous day
Last week
10%
11
Compared to previous week
Last month
3.8%
27
Compared to previous month
Last year
67.9%
319
Compared to previous year
2
Determine if a filename and/or buffer is text or binary. Smarter detection than the other solutions.
Determination works like so:
The extension check will check each of the filename's extensions, from right to left. This is done as certain applications utilise multiple extensions for transformations, such as app.x.y
may tell a compiler to transform from x
format to y
format, in this case perhaps x
is not a recognized extension but y
is, in which case we can make use of that to provide superior accuracy and convenience compared to just checking the rightmost extension.
The contents check (with the default options) will check 24 bytes at the start, middle, and end of the buffer. History has shown that checking all three locations is mandatory for accuracy, and that anything less is not accurate. This technique offers superior performance while still offering superior accuracy. Alternatives generally just do 1000 bytes at the start, which is slower, and inaccurate.
One cannot just do the contents check alone because UTF16 characters are indistinguishable from binary which would return an inaccurate result, hence why the combination is necessary for accuracy, with performance for known extensions a side-effect.
As such, this library's combination of extension check (if filename is provided), then contents check (if buffer is provided), offers superior performance and accuracy to alternatives.
Ever since 2012, this module's superior accuracy and performance has been essential to the operation of DocPad and its other dependents.
1import { isText, isBinary, getEncoding } from 'istextorbinary'
or
1const { isText, isBinary, getEncoding } = require('istextorbinary')
then
1isText(aFilename) // returns true if a text file otherwise false, checks only filename 2isText(null, aBuffer) // returns true if a text file otherwise false, checks only buffer 3isText(aFilename, aBuffer) // returns true if a text file otherwise false, checks filename then buffer 4isText(null, null) // returns null 5 6isBinary(aFilename) // returns true if a binary file otherwise false, checks only filename 7isBinary(null, aBuffer) // returns true if a binary file otherwise false, checks only buffer 8isBinary(aFilename, aBuffer) // returns true if a binary file otherwise false, checks filename then buffer 9isBinary(null, null) // returns null 10 11getEncoding(aBuffer) // returns 'binary' if it contained non-utf8 characters, otherwise returns 'utf8'
npm install --save istextorbinary
import * as pkg from ('istextorbinary')
const pkg = require('istextorbinary')
1<script type="module"> 2 import * as pkg from '//cdn.skypack.dev/istextorbinary@^6.0.0' 3</script>
1<script type="module"> 2 import * as pkg from '//unpkg.com/istextorbinary@^6.0.0' 3</script>
1<script type="module"> 2 import * as pkg from '//dev.jspm.io/istextorbinary@6.0.0' 3</script>
This package is published with the following editions:
istextorbinary/source/index.ts
is TypeScript source code with Import for modulesistextorbinary/edition-browsers/index.js
is TypeScript compiled against ES2020 for web browsers with Import for modulesistextorbinary
aliases istextorbinary/edition-es2019/index.js
istextorbinary/edition-es2019/index.js
is TypeScript compiled against ES2019 for Node.js 10 || 12 || 14 || 16 with Require for modulesistextorbinary/edition-es2019-esm/index.js
is TypeScript compiled against ES2019 for Node.js 12 || 14 || 16 with Import for modulesDiscover the release history by heading on over to the HISTORY.md
file.
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
These amazing people are maintaining this project:
No sponsors yet! Will you be the first?
These amazing people have contributed code to this project:
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
Unless stated otherwise all works are:
and licensed under:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 5
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/18 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-13
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