8000 GitHub - sindresorhus/is-epub: Check if a Buffer/Uint8Array is EPUB
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sindresorhus/is-epub

Repository files navigation

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

About

Check if a Buffer/Uint8Array is EPUB

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  
0