Socket
Socket
Sign inDemoInstall

file-type

Package Overview
Dependencies
11
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 18.0.0 to 18.1.0

8

browser.d.ts

@@ -1,2 +0,2 @@

import {FileTypeResult} from './core.js';
import type {FileTypeResult} from './core.js';

@@ -45,5 +45,5 @@ /**

supportedMimeTypes,
FileTypeResult,
FileExtension,
MimeType,
type FileTypeResult,
type FileExtension,
type MimeType,
} from './core.js';

@@ -1,3 +0,3 @@

import {Readable as ReadableStream} from 'node:stream';
import {ITokenizer} from 'strtok3';
import type {Readable as ReadableStream} from 'node:stream';
import type {ITokenizer} from 'strtok3';

@@ -143,3 +143,6 @@ export type FileExtension =

| 'jxl'
| 'vcf';
| 'vcf'
| 'jls'
| 'pst'
| 'dwg';

@@ -280,5 +283,8 @@ export type MimeType =

| 'image/jxl'
| 'application/zstd';
| 'application/zstd'
| 'image/jls'
| 'application/vnd.ms-outlook'
| 'image/vnd.dwg';
export interface FileTypeResult {
export type FileTypeResult = {
/**

@@ -293,3 +299,3 @@ One of the supported [file types](https://github.com/sindresorhus/file-type#supported-file-types).

readonly mime: MimeType;
}
};

@@ -360,3 +366,3 @@ export type ReadableStreamWithFileType = ReadableStream & {

export interface StreamOptions {
export type StreamOptions = {
/**

@@ -368,3 +374,3 @@ The default sample size in bytes.

readonly sampleSize?: number;
}
};

@@ -371,0 +377,0 @@ /**

@@ -162,9 +162,2 @@ import {Buffer} from 'node:buffer';

if (this.check([0xFF, 0xD8, 0xFF])) {
return {
ext: 'jpg',
mime: 'image/jpeg',
};
}
if (this.check([0x49, 0x49, 0xBC])) {

@@ -226,2 +219,17 @@ return {

// Requires a sample size of 4 bytes
if (this.check([0xFF, 0xD8, 0xFF])) {
if (this.check([0xF7], {offset: 3})) { // JPG7/SOF55, indicating a ISO/IEC 14495 / JPEG-LS file
return {
ext: 'jls',
mime: 'image/jls',
};
}
return {
ext: 'jpg',
mime: 'image/jpeg',
};
}
if (this.checkString('FLIF')) {

@@ -805,2 +813,9 @@ return {

if (this.check([0x21, 0x42, 0x44, 0x4E])) {
return {
ext: 'pst',
mime: 'application/vnd.ms-outlook',
};
}
// -- 5-byte signatures --

@@ -929,2 +944,12 @@

if (this.checkString('AC')) {
const version = this.buffer.toString('binary', 2, 6);
if (version.match('^d*') && version >= 1000 && version <= 1050) {
return {
ext: 'dwg',
mime: 'image/vnd.dwg',
};
}
}
// -- 7-byte signatures --

@@ -1490,4 +1515,4 @@

await this.tokenizer.ignore(ifdOffset);
const fileType = await this.readTiffIFD(false);
return fileType ? fileType : {
const fileType = await this.readTiffIFD(bigEndian);
return fileType ?? {
ext: 'tif',

@@ -1494,0 +1519,0 @@ mime: 'image/tiff',

@@ -1,3 +0,2 @@

import {Readable as ReadableStream} from 'node:stream';
import {FileTypeResult} from './core.js';
import type {FileTypeResult} from './core.js';

@@ -4,0 +3,0 @@ /**

{
"name": "file-type",
"version": "18.0.0",
"version": "18.1.0",
"description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",

@@ -196,3 +196,6 @@ "license": "MIT",

"jxl",
"vcf"
"vcf",
"jls",
"pst",
"dwg"
],

@@ -207,7 +210,7 @@ "dependencies": {

"@types/node": "^18.7.13",
"ava": "^4.3.1",
"ava": "^5.1.0",
"commonmark": "^0.30.0",
"noop-stream": "^1.0.0",
"tsd": "^0.22.0",
"xo": "^0.51.0"
"tsd": "^0.25.0",
"xo": "^0.53.1"
},

@@ -224,3 +227,5 @@ "xo": {

"@typescript-eslint/no-unsafe-assignment": "off",
"unicorn/text-encoding-identifier-case": "off"
"unicorn/text-encoding-identifier-case": "off",
"unicorn/switch-case-braces": "off",
"unicorn/prefer-top-level-await": "off"
}

@@ -227,0 +232,0 @@ },

@@ -379,2 +379,3 @@ # file-type

- [`dsf`](https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf) - Sony DSD Stream File (DSF)
- [`dwg`](https://en.wikipedia.org/wiki/.dwg) - Autodesk CAD file
- [`elf`](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) - Unix Executable and Linkable Format

@@ -401,2 +402,3 @@ - [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType) - Embedded OpenType font

- [`it`](https://wiki.openmpt.org/Manual:_Module_formats#The_Impulse_Tracker_format_.28.it.29) - Audio module format: Impulse Tracker
- [`jls`](https://en.wikipedia.org/wiki/Lossless_JPEG#JPEG-LS) - Lossless/near-lossless compression standard for continuous-tone images
- [`jp2`](https://en.wikipedia.org/wiki/JPEG_2000) - JPEG 2000

@@ -415,3 +417,3 @@ - [`jpg`](https://en.wikipedia.org/wiki/JPEG) - Joint Photographic Experts Group image

- [`m4p`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions) - MPEG-4 files with audio streams encrypted by FairPlay Digital Rights Management as were sold through the iTunes Store
- [`m4v`](https://en.wikipedia.org/wiki/M4V) - MPEG-4 Visual bitstreams
- [`m4v`](https://en.wikipedia.org/wiki/M4V) - Video container format developed by Apple, which is very similar to the MP4 format
- [`mid`](https://en.wikipedia.org/wiki/MIDI) - Musical Instrument Digital Interface file

@@ -451,2 +453,3 @@ - [`mie`](https://en.wikipedia.org/wiki/Sidecar_file) - Dedicated meta information format which supports storage of binary as well as textual meta information

- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format) - Adobe Photoshop document
- [`pst`](https://en.wikipedia.org/wiki/Personal_Storage_Table) - Personal Storage Table file
- [`qcp`](https://en.wikipedia.org/wiki/QCP) - Tagged and chunked data

@@ -497,8 +500,2 @@ - [`raf`](https://en.wikipedia.org/wiki/Raw_image_format) - Fujifilm RAW image file

## file-type for enterprise
Available as part of the Tidelift Subscription.
The maintainers of file-type and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-file-type?utm_source=npm-file-type&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Related

@@ -511,4 +508,7 @@

- [Sindre Sorhus](https://github.com/sindresorhus)
- [Borewit](https://github.com/Borewit)
**Former**
- [Mikael Finstad](https://github.com/mifi)
- [Ben Brook](https://github.com/bencmbrook)
- [Borewit](https://github.com/Borewit)

@@ -141,2 +141,5 @@ export const extensions = [

'vcf',
'jls',
'pst',
'dwg',
];

@@ -279,2 +282,5 @@

'application/zstd',
'image/jls',
'application/vnd.ms-outlook',
'image/vnd.dwg',
];
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc