file-type
Advanced tools
Comparing version 0.1.1 to 0.2.0
10
index.js
'use strict'; | ||
module.exports = function (buf) { | ||
if (!buf || buf.length < 12) { | ||
if (!buf) { | ||
return false; | ||
} | ||
if (require('is-pdf')(buf)) { | ||
return 'pdf'; | ||
} | ||
if (require('is-epub')(buf)) { | ||
return 'epub'; | ||
} | ||
return require('image-type')(buf) || require('archive-type')(buf) || false; | ||
}; |
{ | ||
"name": "file-type", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Detect the file type of a Buffer/Uint8Array", | ||
@@ -63,2 +63,4 @@ "license": "MIT", | ||
"image-type": "^0.1.1", | ||
"is-epub": "^0.1.0", | ||
"is-pdf": "^0.1.0", | ||
"read-chunk": "^0.1.0" | ||
@@ -65,0 +67,0 @@ }, |
@@ -28,3 +28,3 @@ # file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type) | ||
var fileType = require('file-type'); | ||
var buffer = readChunk('unicorn.png', 0, 12); | ||
var buffer = readChunk('unicorn.png', 0, 58); | ||
@@ -61,3 +61,3 @@ fileType(buffer); | ||
It only needs the first 12 bytes. | ||
It only needs the first 58 bytes. | ||
@@ -100,2 +100,4 @@ | ||
- [`zip`](https://github.com/kevva/is-zip) | ||
- [`pdf`](https://github.com/kevva/is-pdf) | ||
- [`epub`](https://github.com/sindresorhus/is-epub) | ||
@@ -102,0 +104,0 @@ *PR welcome for additional file types* |
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
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
4531
58
107
5
+ Addedis-epub@^0.1.0
+ Addedis-pdf@^0.1.0
+ Addedis-epub@0.1.2(transitive)
+ Addedis-pdf@0.1.0(transitive)