Socket
Socket
Sign inDemoInstall

file-type

Package Overview
Dependencies
Maintainers
2
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-type - npm Package Compare versions

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;
};

12

package.json
{
"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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc