Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.3.0 to 1.0.0

36

cli.js

@@ -5,15 +5,19 @@ #!/usr/bin/env node

var pkg = require('./package.json');
var fileType = require('./index');
var input = process.argv[2];
var fileType = require('./');
var argv = process.argv.slice(2);
var input = argv[0];
function help() {
console.log(pkg.description);
console.log('');
console.log('Usage');
console.log(' $ cat <filename> | file-type');
console.log(' $ file-type <filename>');
console.log('');
console.log('Example');
console.log(' $ cat unicorn.png | file-type');
console.log(' png');
console.log([
'',
' ' + pkg.description,
'',
' Usage',
' file-type <filename>',
' cat <filename> | file-type',
'',
' Example',
' cat unicorn.png | file-type',
' png'
].join('\n'));
}

@@ -32,3 +36,3 @@

if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
if (argv.indexOf('--help') !== -1) {
help();

@@ -38,3 +42,3 @@ return;

if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
if (argv.indexOf('--version') !== -1) {
console.log(pkg.version);

@@ -50,7 +54,5 @@ return;

init(readChunk.sync(input, 0, 12));
init(readChunk.sync(input, 0, 262));
} else {
process.stdin.once('data', function (data) {
init(data);
});
process.stdin.once('data', init);
}

@@ -21,5 +21,9 @@ 'use strict';

return 'mp4';
}
}
return require('image-type')(buf) || require('archive-type')(buf) || require ('audio-type')(buf)|| false;
if (require('is-swf')(buf)) {
return 'swf';
}
return require('image-type')(buf) || require('archive-type')(buf) || require ('audio-type')(buf) || false;
};
{
"name": "file-type",
"version": "0.3.0",
"version": "1.0.0",
"description": "Detect the file type of a Buffer/Uint8Array",
"license": "MIT",
"repository": "sindresorhus/file-type",
"bin": {
"file-type": "cli.js"
},
"author": {

@@ -15,2 +12,5 @@ "name": "Sindre Sorhus",

},
"bin": {
"file-type": "cli.js"
},
"engines": {

@@ -20,4 +20,3 @@ "node": ">=0.10.0"

"scripts": {
"test": "mocha",
"browser": "browserify -s $npm_package_name -o browser.js ."
"test": "mocha"
},

@@ -29,2 +28,3 @@ "files": [

"keywords": [
"mime",
"file",

@@ -37,2 +37,3 @@ "type",

"picture",
"flash",
"photo",

@@ -63,2 +64,3 @@ "video",

"rar",
"swf",
"tar",

@@ -69,15 +71,15 @@ "zip",

"dependencies": {
"archive-type": "^0.1.1",
"audio-type": "^0.1.0",
"image-type": "^0.1.1",
"is-epub": "^0.1.0",
"archive-type": "^0.1.4",
"audio-type": "^0.1.4",
"image-type": "^1.0.0",
"is-epub": "^0.1.2",
"is-exe": "^0.1.0",
"is-mp4": "^0.1.0",
"is-pdf": "^0.1.0",
"read-chunk": "^0.1.0",
"is-mp4": "^0.1.0"
"is-swf": "^0.1.0"
},
"devDependencies": {
"browserify": "^3.0.0",
"mocha": "*"
"mocha": "*",
"read-chunk": "^1.0.0"
}
}

@@ -14,11 +14,3 @@ # file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type)

```sh
$ bower install --save file-type
```
```sh
$ component install sindresorhus/file-type
```
## Usage

@@ -37,2 +29,18 @@

or from a remote location:
```js
var http = require('http');
var fileType = require('file-type');
var url = 'http://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
http.get(url, function (res) {
res.once('data', function (chunk) {
res.destroy();
console.log(fileType(chunk));
//=> gif
});
});
```
##### Browser

@@ -76,9 +84,9 @@

Usage
$ cat <filename> | file-type
$ file-type <filename>
Usage
file-type <filename>
cat <filename> | file-type
Example
$ cat unicorn.png | file-type
png
Example
cat unicorn.png | file-type
png
```

@@ -112,6 +120,7 @@

- [`mp4`](https://github.com/deepak1556/is-mp4)
- [`swf`](https://github.com/kevva/is-swf)
*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*
*PR welcome for additional commonly used file types.*

@@ -118,0 +127,0 @@

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