Socket
Socket
Sign inDemoInstall

file-type

Package Overview
Dependencies
Maintainers
2
Versions
150
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.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;
};

4

package.json
{
"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*

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc