is-epub

2.0.0 • Public • Published

is-epub

Check if a Buffer/Uint8Array is EPUB

Install

$ npm install is-epub

Usage

Node.js
import readChunk from 'read-chunk';
import isEpub from 'is-epub';

const buffer = readChunk.sync('unicorn.epub', 0, 58);

isEpub(buffer);
//=> true
Browser
import isEpub from 'is-epub';

const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.epub');
xhr.responseType = 'arraybuffer';

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

xhr.send();

API

isEpub(buffer)

Accepts a Buffer (Node.js) or Uint8Array.

It only needs the first 58 bytes.

Related

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

Dependents (2)

Package Sidebar

Install

npm i is-epub

Weekly Downloads

3

Version

2.0.0

License

MIT

Unpacked Size

2.81 kB

Total Files

4

Last publish

Collaborators

  • sindresorhus