Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/t1st3/is-7z
Check if a Buffer/Uint8Array is a 7Z archive
https://github.com/t1st3/is-7z
7-zip 7z buffer detect file javascript magic-numbers uint8array
Last synced: 29 days ago
JSON representation
Check if a Buffer/Uint8Array is a 7Z archive
- Host: GitHub
- URL: https://github.com/t1st3/is-7z
- Owner: t1st3
- License: mit
- Created: 2016-01-19T20:59:42.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:18:36.000Z (over 4 years ago)
- Last Synced: 2024-12-02T21:21:34.910Z (about 2 months ago)
- Topics: 7-zip, 7z, buffer, detect, file, javascript, magic-numbers, uint8array
- Language: JavaScript
- Size: 74.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# is-7z
[![NPM version](https://img.shields.io/npm/v/is-7z.svg)](https://www.npmjs.com/package/is-7z)
[![Build Status](https://travis-ci.org/t1st3/is-7z.svg?branch=master)](https://travis-ci.org/t1st3/is-7z)> Check if a Buffer/Uint8Array is a [7Z](https://en.wikipedia.org/wiki/7z) archive.
## Install
```sh
$ npm install --save is-7z
```## Usage
### Node.js
```js
var readChunk = require('read-chunk'); // npm install read-chunk
var is7z = require('is-7z');
var buffer = readChunk.sync('unicorn.7z', 0, 6);is7z(buffer);
//=> true
```### Browser
```js
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.7z');
xhr.responseType = 'arraybuffer';xhr.onload = function () {
is7z(new Uint8Array(this.response));
//=> true
};xhr.send();
```## API
### is7z(buffer)
Accepts a Buffer (Node.js) or Uint8Array.
It only needs the first 6 bytes.
## License
MIT © [t1st3](https://t1st3.com)