file-type 17.0.0 → 17.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core.d.ts CHANGED
@@ -49,6 +49,7 @@ export type FileExtension =
49
49
  | 'pdf'
50
50
  | 'epub'
51
51
  | 'mobi'
52
+ | 'elf'
52
53
  | 'exe'
53
54
  | 'swf'
54
55
  | 'rtf'
@@ -195,6 +196,7 @@ export type MimeType =
195
196
  | 'audio/wavpack'
196
197
  | 'audio/amr'
197
198
  | 'application/pdf'
199
+ | 'application/x-elf'
198
200
  | 'application/x-msdownload'
199
201
  | 'application/x-shockwave-flash'
200
202
  | 'application/rtf'
package/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import {Buffer} from 'node:buffer';
2
- import Token from 'token-types';
2
+ import * as Token from 'token-types';
3
3
  import * as strtok3 from 'strtok3/core';
4
4
  import {
5
5
  stringToBytes,
@@ -151,6 +151,13 @@ class FileTypeParser {
151
151
 
152
152
  // -- 3-byte signatures --
153
153
 
154
+ if (this.check([0x47, 0x49, 0x46])) {
155
+ return {
156
+ ext: 'gif',
157
+ mime: 'image/gif',
158
+ };
159
+ }
160
+
154
161
  if (this.check([0xFF, 0xD8, 0xFF])) {
155
162
  return {
156
163
  ext: 'jpg',
@@ -214,13 +221,6 @@ class FileTypeParser {
214
221
 
215
222
  // -- 4-byte signatures --
216
223
 
217
- if (this.check([0x47, 0x49, 0x46])) {
218
- return {
219
- ext: 'gif',
220
- mime: 'image/gif',
221
- };
222
- }
223
-
224
224
  if (this.checkString('FLIF')) {
225
225
  return {
226
226
  ext: 'flif',
@@ -477,6 +477,7 @@ class FileTypeParser {
477
477
  const brandMajor = this.buffer.toString('binary', 8, 12).replace('\0', ' ').trim();
478
478
  switch (brandMajor) {
479
479
  case 'avif':
480
+ case 'avis':
480
481
  return {ext: 'avif', mime: 'image/avif'};
481
482
  case 'mif1':
482
483
  return {ext: 'heic', mime: 'image/heif'};
@@ -790,6 +791,13 @@ class FileTypeParser {
790
791
  };
791
792
  }
792
793
 
794
+ if (this.check([0x7F, 0x45, 0x4C, 0x46])) {
795
+ return {
796
+ ext: 'elf',
797
+ mime: 'application/x-elf',
798
+ };
799
+ }
800
+
793
801
  // -- 5-byte signatures --
794
802
 
795
803
  if (this.check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-type",
3
- "version": "17.0.0",
3
+ "version": "17.1.1",
4
4
  "description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",
@@ -51,6 +51,7 @@
51
51
  "check",
52
52
  "is",
53
53
  "exif",
54
+ "elf",
54
55
  "exe",
55
56
  "binary",
56
57
  "buffer",
@@ -196,8 +197,8 @@
196
197
  ],
197
198
  "dependencies": {
198
199
  "readable-web-to-node-stream": "^3.0.2",
199
- "strtok3": "7.0.0-alpha.4",
200
- "token-types": "^4.1.1"
200
+ "strtok3": "^7.0.0-alpha.7",
201
+ "token-types": "^5.0.0-alpha.2"
201
202
  },
202
203
  "devDependencies": {
203
204
  "@tokenizer/token": "^0.3.0",
package/readme.md CHANGED
@@ -6,6 +6,8 @@ The file type is detected by checking the [magic number](https://en.wikipedia.or
6
6
 
7
7
  This package is for detecting binary-based file formats, not text-based formats like `.txt`, `.csv`, `.svg`, etc.
8
8
 
9
+ We accept contributions for commonly used modern file formats, not historical or obscure ones. Open an issue first for discussion.
10
+
9
11
  <br>
10
12
 
11
13
  ---
@@ -371,6 +373,7 @@ Returns a `Set<string>` of supported MIME types.
371
373
  - [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format) - Portable Document Format
372
374
  - [`epub`](https://en.wikipedia.org/wiki/EPUB) - E-book file
373
375
  - [`mobi`](https://en.wikipedia.org/wiki/Mobipocket) - Mobipocket
376
+ - [`elf`](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) - Unix Executable and Linkable Format
374
377
  - [`exe`](https://en.wikipedia.org/wiki/.exe) - Executable file
375
378
  - [`swf`](https://en.wikipedia.org/wiki/SWF) - Adobe Flash Player file
376
379
  - [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format) - Rich Text Format
package/supported.js CHANGED
@@ -47,6 +47,7 @@ export const extensions = [
47
47
  'amr',
48
48
  'pdf',
49
49
  'epub',
50
+ 'elf',
50
51
  'exe',
51
52
  'swf',
52
53
  'rtf',
@@ -193,6 +194,7 @@ export const mimeTypes = [
193
194
  'audio/wavpack',
194
195
  'audio/amr',
195
196
  'application/pdf',
197
+ 'application/x-elf',
196
198
  'application/x-msdownload',
197
199
  'application/x-shockwave-flash',
198
200
  'application/rtf',