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 2.12.0 to 3.0.0

13

package.json
{
"name": "file-type",
"version": "2.12.0",
"version": "3.0.0",
"description": "Detect the file type of a Buffer/Uint8Array",

@@ -12,3 +12,2 @@ "license": "MIT",

},
"bin": "cli.js",
"engines": {

@@ -21,8 +20,5 @@ "node": ">=0.10.0"

"files": [
"index.js",
"cli.js"
"index.js"
],
"keywords": [
"cli-app",
"cli",
"mime",

@@ -93,10 +89,7 @@ "file",

],
"dependencies": {
"meow": "^3.3.0",
"read-chunk": "^1.0.1"
},
"devDependencies": {
"ava": "*",
"read-chunk": "^1.0.1",
"xo": "*"
}
}

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

```js
var readChunk = require('read-chunk'); // npm install read-chunk
var fileType = require('file-type');
var buffer = readChunk.sync('unicorn.png', 0, 262);
const readChunk = require('read-chunk'); // npm install read-chunk
const fileType = require('file-type');
const buffer = readChunk.sync('unicorn.png', 0, 262);

@@ -32,8 +32,8 @@ fileType(buffer);

```js
var http = require('http');
var fileType = require('file-type');
var url = 'http://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
const http = require('http');
const fileType = require('file-type');
const url = 'http://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
http.get(url, function (res) {
res.once('data', function (chunk) {
http.get(url, res => {
res.once('data', chunk => {
res.destroy();

@@ -49,7 +49,7 @@ console.log(fileType(chunk));

```js
var xhr = new XMLHttpRequest();
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.png');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
xhr.onload = () => {
fileType(new Uint8Array(this.response));

@@ -79,21 +79,2 @@ //=> {ext: 'png', mime: 'image/png'}

## CLI
```
$ npm install --global file-type
```
```
$ file-type --help
Usage
file-type <filename>
cat <filename> | file-type
Example
cat unicorn.png | file-type
png
```
## Supported file types

@@ -152,4 +133,9 @@

## Related
- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
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