Check if a Buffer/Uint8Array is a 7Z archive.
$ npm install --save is-7z
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
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.7z');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
is7z(new Uint8Array(this.response));
//=> true
};
xhr.send();
Accepts a Buffer (Node.js) or Uint8Array.
It only needs the first 6 bytes.
MIT © t1st3