$ npm install @xhmikosr/archive-type
Detect the archive type of a Buffer/Uint8Array
npm install @xhmikosr/archive-type
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'}
Returns an Object with:
ext - One of the supported file typesmime - The MIME typeOr null when no match.
Type: Buffer Uint8Array
It only needs the first 262 bytes.
7zbz2gzpkgrartartar.gzxzzipzstMIT © Kevin Mårtensson
© 2010 - cnpmjs.org x YWFE | Home | YWFE