Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@xhmikosr/archive-type

XhmikosR3mMIT7.0.0

Detect the archive type of a Buffer/Uint8Array

7zip, archive, buffer, bz2, bzip2, check, detect, gz, gzip, mime, rar, zip, zst, zstd, file, type

readme

archive-type CI

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:

Or null when no match.

input

Type: Buffer Uint8Array

It only needs the first 262 bytes.

Supported file types

  • 7z
  • bz2
  • gz
  • rar
  • tar
  • zip
  • xz
  • gz
  • zst

License

MIT © Kevin Mårtensson