# archive-type

> Detect the archive type of a Buffer/Uint8Array

Latest version **4.0.0** (published 2017-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install archive-type
pnpm add archive-type
yarn add archive-type
bun add archive-type
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2017-04-25 |
| First published | 2014-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Kevin Mårtensson |
| Maintainers | kevva, sindresorhus |
| Keywords | 7zip, archive, buffer, bz2, bzip2, check, detect, gz, gzip, mime, rar, zip, file, type |

## Links

- npm: https://www.npmjs.com/package/archive-type
- Repository: https://github.com/kevva/archive-type
- Homepage: https://github.com/kevva/archive-type#readme
- Issues: https://github.com/kevva/archive-type/issues
- npm.io page: https://npm.io/package/archive-type

## Dependencies (1)

- [file-type](https://npm.io/package/file-type.md) ^4.2.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 4.0.0 (latest) — 2017-04-25
- 3.2.0 — 2016-01-03
- 3.1.0 — 2015-12-14
- 3.0.2 — 2015-11-05
- 3.0.1 — 2015-08-12
- 3.0.0 — 2015-07-17
- 2.1.0 — 2015-04-09
- 2.0.0 — 2015-01-12
- 1.0.4 — 2014-10-28
- 1.0.3 — 2014-10-04
- 1.0.2 — 2014-08-25
- 1.0.1 — 2014-08-20
- 1.0.0 — 2014-08-17
- 0.1.4 — 2014-08-12
- 0.1.3 — 2014-08-12
- … 3 more at https://npm.io/package/archive-type/versions

## README

# archive-type [![Build Status](https://travis-ci.org/kevva/archive-type.svg?branch=master)](https://travis-ci.org/kevva/archive-type)

> Detect the archive type of a Buffer/Uint8Array


## Install

```
$ npm install --save archive-type
```


## Usage

```js
const archiveType = require('archive-type');
const readChunk = require('read-chunk');
const buffer = readChunk.sync('unicorn.zip', 0, 262);

archiveType(buffer);
//=> {ext: 'zip', mime: 'application/zip'}
```


## API

### archiveType(input)

Returns an `Object` with:

- `ext` - One of the [supported file types](#supported-file-types)
- `mime` - The [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)

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`


## Related

- [archive-type-cli](https://github.com/kevva/archive-type-cli) - CLI for this module


## License

MIT © [Kevin Mårtensson](https://github.com/kevva)

---
_Source: https://npm.io/package/archive-type · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
