Skip to content

Detect the archive type of a Buffer/Uint8Array

License

Notifications You must be signed in to change notification settings

XhmikosR/archive-type

 
 

Repository files navigation

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

Related

License

MIT © Kevin Mårtensson

About

Detect the archive type of a Buffer/Uint8Array

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%