is-jxr
Version:
Check if a Buffer/Uint8Array is a JPEG XR image
51 lines (32 loc) • 770 B
Markdown
> Check if a Buffer/Uint8Array is a [JPEG XR](https://en.wikipedia.org/wiki/JPEG_XR) image
```sh
npm install is-jxr
```
```js
import {readChunk} from 'read-chunk';
import isJxr from 'is-jxr';
const buffer = await readChunk('unicorn.jxr', {length: 3});
isJxr(buffer);
//=> true
```
```js
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.jxr');
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
isJxr(new Uint8Array(this.response));
//=> true
};
xhr.send();
```
Accepts a `Buffer` (Node.js) or `Uint8Array`.
It only needs the first 3 bytes.
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array