Licence
MIT
Version
8.1.0
Deps
1
Size
4 kB
Vulns
0
Weekly
0
@xhmikosr/archive-type

Detect the archive type of a Buffer/Uint8Array
Install
npm install @xhmikosr/archive-type
Usage
import archiveType from '@xhmikosr/archive-type';
import {readChunk} from 'read-chunk';
const buffer = await readChunk('unicorn.zip', 0, 262);
await archiveType(buffer);
//=> {ext: 'zip', mime: 'application/zip'}
API
archiveType(input)
Returns an Object with:
ext- One of the supported file typesmime- The MIME type
Or null when no match.
input
Type: Buffer Uint8Array
It only needs the first 262 bytes.
Supported file types
7zbz2gzpkgrartartar.gzxzzipzst
Related
- archive-type-cli - CLI for this module
License
MIT Kevin Mårtensson