Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/t1st3/is-rpm
Check if a Buffer/Uint8Array is a RPM file
https://github.com/t1st3/is-rpm
buffer detect file javascript magic-numbers rpm uint8array
Last synced: 3 days ago
JSON representation
Check if a Buffer/Uint8Array is a RPM file
- Host: GitHub
- URL: https://github.com/t1st3/is-rpm
- Owner: t1st3
- License: mit
- Created: 2016-01-22T12:51:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:18:55.000Z (over 4 years ago)
- Last Synced: 2023-08-24T03:21:36.905Z (about 1 year ago)
- Topics: buffer, detect, file, javascript, magic-numbers, rpm, uint8array
- Language: JavaScript
- Size: 67.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# is-rpm
[![NPM version](https://img.shields.io/npm/v/is-rpm.svg)](https://www.npmjs.com/package/is-rpm)
[![Build Status](https://travis-ci.org/t1st3/is-rpm.svg?branch=master)](https://travis-ci.org/t1st3/is-rpm)> Check if a Buffer/Uint8Array is a [RPM](https://en.wikipedia.org/wiki/RPM_Package_Manager) package.
## Install
```sh
$ npm install --save is-rpm
```## Usage
### Node.js
```js
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
```### Browser
```js
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.rpm');
xhr.responseType = 'arraybuffer';xhr.onload = function () {
isRpm(new Uint8Array(this.response));
//=> true
};xhr.send();
```## API
### isRpm(buffer)
Accepts a Buffer (Node.js) or Uint8Array.
It only needs the first 4 bytes.
## License
MIT © [t1st3](https://t1st3.com)