Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

is-jxr

sindresorhus1.4kMIT2.0.0

Check if a Buffer/Uint8Array is a JPEG XR image

jxr, jpeg xr, jpg, jpeg, image, img, pic, picture, photo, type, detect, check, is, exif, binary, buffer, uint8array, cli, bin

readme

is-jxr

Check if a Buffer/Uint8Array is a JPEG XR image

Install

npm install is-jxr

Usage

Node.js
import {readChunk} from 'read-chunk';
import isJxr from 'is-jxr';

const buffer = await readChunk('unicorn.jxr', {length: 3});

isJxr(buffer);
//=> true
Browser
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.jxr');
xhr.responseType = 'arraybuffer';

xhr.onload = () => {
    isJxr(new Uint8Array(this.response));
    //=> true
};

xhr.send();

API

isJxr(buffer)

Accepts a Buffer (Node.js) or Uint8Array.

It only needs the first 3 bytes.

  • file-type - Detect the file type of a Buffer/Uint8Array