file-type
Advanced tools
Comparing version 0.2.0 to 0.3.0
10
index.js
@@ -15,3 +15,11 @@ 'use strict'; | ||
return require('image-type')(buf) || require('archive-type')(buf) || false; | ||
if (require('is-exe')(buf)) { | ||
return 'exe'; | ||
} | ||
if (require('is-mp4')(buf)) { | ||
return 'mp4'; | ||
} | ||
return require('image-type')(buf) || require('archive-type')(buf) || require ('audio-type')(buf)|| false; | ||
}; |
{ | ||
"name": "file-type", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Detect the file type of a Buffer/Uint8Array", | ||
@@ -35,2 +35,3 @@ "license": "MIT", | ||
"photo", | ||
"video", | ||
"type", | ||
@@ -41,2 +42,3 @@ "detect", | ||
"exif", | ||
"exe", | ||
"binary", | ||
@@ -60,10 +62,14 @@ "buffer", | ||
"tar", | ||
"zip" | ||
"zip", | ||
"mp4" | ||
], | ||
"dependencies": { | ||
"archive-type": "^0.1.1", | ||
"audio-type": "^0.1.0", | ||
"image-type": "^0.1.1", | ||
"is-epub": "^0.1.0", | ||
"is-exe": "^0.1.0", | ||
"is-pdf": "^0.1.0", | ||
"read-chunk": "^0.1.0" | ||
"read-chunk": "^0.1.0", | ||
"is-mp4": "^0.1.0" | ||
}, | ||
@@ -70,0 +76,0 @@ "devDependencies": { |
@@ -5,3 +5,5 @@ # file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type) | ||
The file type is detected by checking the [magic number](http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer. | ||
## Install | ||
@@ -29,3 +31,3 @@ | ||
var fileType = require('file-type'); | ||
var buffer = readChunk('unicorn.png', 0, 58); | ||
var buffer = readChunk.sync('unicorn.png', 0, 262); | ||
@@ -62,3 +64,3 @@ fileType(buffer); | ||
It only needs the first 58 bytes. | ||
It only needs the first 262 bytes. | ||
@@ -103,8 +105,17 @@ | ||
- [`epub`](https://github.com/sindresorhus/is-epub) | ||
- [`exe`](https://github.com/kevva/is-exe) | ||
- [`mp3`](https://github.com/hemanth/is-mp3) | ||
- [`flac`](https://github.com/hemanth/is-flac) | ||
- [`wav`](https://github.com/hemanth/is-wav) | ||
- [`ogg`](https://github.com/hemanth/is-ogg) | ||
- [`m4a`](https://github.com/hemanth/is-m4a) | ||
- [`mp4`](https://github.com/deepak1556/is-mp4) | ||
*PR welcome for additional file types* | ||
*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).* | ||
*PR welcome for additional commonly used file types* | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
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
5398
64
118
8
+ Addedaudio-type@^0.1.0
+ Addedis-exe@^0.1.0
+ Addedis-mp4@^0.1.0
+ Addedaudio-type@0.1.4(transitive)
+ Addedis-exe@0.1.0(transitive)
+ Addedis-flac@0.1.2(transitive)
+ Addedis-m4a@0.1.2(transitive)
+ Addedis-mp3@0.1.1(transitive)
+ Addedis-mp4@0.1.0(transitive)
+ Addedis-ogg@0.1.2(transitive)
+ Addedis-wav@0.1.2(transitive)