Comparing version 1.0.1 to 2.0.0
14
index.js
@@ -1,9 +0,11 @@ | ||
'use strict'; | ||
module.exports = function (buf) { | ||
if (!buf || buf.length < 58) { | ||
export default function isEpub(buffer) { | ||
if (!buffer || buffer.length < 58) { | ||
return false; | ||
} | ||
return buf[0] === 80 && buf[1] === 75 && buf[2] === 3 && buf[3] === 4 && | ||
buf.slice(30, 58).toString() === 'mimetypeapplication/epub+zip'; | ||
}; | ||
return buffer[0] === 80 && | ||
buffer[1] === 75 && | ||
buffer[2] === 3 && | ||
buffer[3] === 4 && | ||
buffer.slice(30, 58).toString() === 'mimetypeapplication/epub+zip'; | ||
} |
{ | ||
"name": "is-epub", | ||
"version": "1.0.1", | ||
"description": "Check if a Buffer/Uint8Array is EPUB", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-epub", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"epub", | ||
"ebook", | ||
"book", | ||
"type", | ||
"detect", | ||
"check", | ||
"is", | ||
"binary", | ||
"buffer", | ||
"uint8array" | ||
], | ||
"devDependencies": { | ||
"mocha": "*", | ||
"read-chunk": "^1.0.0" | ||
} | ||
"name": "is-epub", | ||
"version": "2.0.0", | ||
"description": "Check if a Buffer/Uint8Array is EPUB", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-epub", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"scripts": { | ||
"test": "ava && xo" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"epub", | ||
"ebook", | ||
"book", | ||
"type", | ||
"detect", | ||
"check", | ||
"is", | ||
"binary", | ||
"buffer", | ||
"uint8array" | ||
], | ||
"devDependencies": { | ||
"ava": "^3.15.0", | ||
"read-chunk": "^2.1.0", | ||
"xo": "^0.39.1" | ||
} | ||
} |
@@ -1,15 +0,11 @@ | ||
# is-epub [![Build Status](https://travis-ci.org/sindresorhus/is-epub.svg?branch=master)](https://travis-ci.org/sindresorhus/is-epub) | ||
# is-epub | ||
> Check if a Buffer/Uint8Array is [EPUB](http://en.wikipedia.org/wiki/EPUB) | ||
> Check if a Buffer/Uint8Array is [EPUB](https://en.wikipedia.org/wiki/EPUB) | ||
Used by [file-type](https://github.com/sindresorhus/file-type). | ||
## Install | ||
```sh | ||
$ npm install --save is-epub | ||
``` | ||
$ npm install is-epub | ||
``` | ||
## Usage | ||
@@ -20,6 +16,7 @@ | ||
```js | ||
var readChunk = require('read-chunk'); // npm install read-chunk | ||
var isEpub = require('is-epub'); | ||
var buffer = readChunk.sync('unicorn.epub', 0, 58); | ||
import readChunk from 'read-chunk'; | ||
import isEpub from 'is-epub'; | ||
const buffer = readChunk.sync('unicorn.epub', 0, 58); | ||
isEpub(buffer); | ||
@@ -32,7 +29,9 @@ //=> true | ||
```js | ||
var xhr = new XMLHttpRequest(); | ||
import isEpub from 'is-epub'; | ||
const xhr = new XMLHttpRequest(); | ||
xhr.open('GET', 'unicorn.epub'); | ||
xhr.responseType = 'arraybuffer'; | ||
xhr.onload = function () { | ||
xhr.onload = () => { | ||
isEpub(new Uint8Array(this.response)); | ||
@@ -45,3 +44,2 @@ //=> true | ||
## API | ||
@@ -55,5 +53,4 @@ | ||
## Related | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
- [file-type](https://github.com/sindresorhus/file-type) - Detect the file type of a Buffer/Uint8Array |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
10
Yes
2808
3
53