Check if a Buffer/Uint8Array is a RPM package.
$ npm install --save is-rpm
var readChunk = require('read-chunk'); // npm install read-chunk
var isRpm = require('is-rpm');
var buffer = readChunk.sync('unicorn.rpm', 0, 4);
isRpm(buffer);
//=> true
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.rpm');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
isRpm(new Uint8Array(this.response));
//=> true
};
xhr.send();
Accepts a Buffer (Node.js) or Uint8Array.
It only needs the first 4 bytes.
MIT © t1st3