Detect the archive type of a Buffer/Uint8Array
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.editorconfig
.gitattributes
.gitignore
.travis.yml
index.js
license
package.json
readme.md

readme.md

archive-type Build Status

Detect the archive type of a Buffer/Uint8Array

Install

$ npm install --save archive-type

Usage

const fs = require('fs');
const archiveType = require('archive-type');

fs.readFile('foo.zip', (err, data) => {
    archiveType(data);
    //=> {ext: 'zip', mime: 'application/zip'}
});

API

archiveType(buf)

Returns 7z, bz2, gz, rar, tar, zip, xz or false.

buf

Type: buffer (Node.js), uint8array

It only needs the first 261 bytes.

Related

License

MIT © Kevin Mårtensson