file-type 20.0.1 → 20.1.0

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.
Files changed (3) hide show
  1. package/core.js +32 -32
  2. package/package.json +1 -1
  3. package/readme.md +2 -0
package/core.js CHANGED
@@ -476,13 +476,6 @@ export class FileTypeParser {
476
476
  };
477
477
  }
478
478
 
479
- if (this.checkString('WEBP', {offset: 8})) {
480
- return {
481
- ext: 'webp',
482
- mime: 'image/webp',
483
- };
484
- }
485
-
486
479
  // Musepack, SV8
487
480
  if (this.checkString('MPCK')) {
488
481
  return {
@@ -851,31 +844,6 @@ export class FileTypeParser {
851
844
  }
852
845
  }
853
846
 
854
- // RIFF file format which might be AVI, WAV, QCP, etc
855
- if (this.check([0x52, 0x49, 0x46, 0x46])) {
856
- if (this.check([0x41, 0x56, 0x49], {offset: 8})) {
857
- return {
858
- ext: 'avi',
859
- mime: 'video/vnd.avi',
860
- };
861
- }
862
-
863
- if (this.check([0x57, 0x41, 0x56, 0x45], {offset: 8})) {
864
- return {
865
- ext: 'wav',
866
- mime: 'audio/wav',
867
- };
868
- }
869
-
870
- // QLCM, QCP file
871
- if (this.check([0x51, 0x4C, 0x43, 0x4D], {offset: 8})) {
872
- return {
873
- ext: 'qcp',
874
- mime: 'audio/qcelp',
875
- };
876
- }
877
- }
878
-
879
847
  if (this.checkString('SQLi')) {
880
848
  return {
881
849
  ext: 'sqlite',
@@ -1307,6 +1275,38 @@ export class FileTypeParser {
1307
1275
 
1308
1276
  // -- 12-byte signatures --
1309
1277
 
1278
+ // RIFF file format which might be AVI, WAV, QCP, etc
1279
+ if (this.check([0x52, 0x49, 0x46, 0x46])) {
1280
+ if (this.checkString('WEBP', {offset: 8})) {
1281
+ return {
1282
+ ext: 'webp',
1283
+ mime: 'image/webp',
1284
+ };
1285
+ }
1286
+
1287
+ if (this.check([0x41, 0x56, 0x49], {offset: 8})) {
1288
+ return {
1289
+ ext: 'avi',
1290
+ mime: 'video/vnd.avi',
1291
+ };
1292
+ }
1293
+
1294
+ if (this.check([0x57, 0x41, 0x56, 0x45], {offset: 8})) {
1295
+ return {
1296
+ ext: 'wav',
1297
+ mime: 'audio/wav',
1298
+ };
1299
+ }
1300
+
1301
+ // QLCM, QCP file
1302
+ if (this.check([0x51, 0x4C, 0x43, 0x4D], {offset: 8})) {
1303
+ return {
1304
+ ext: 'qcp',
1305
+ mime: 'audio/qcelp',
1306
+ };
1307
+ }
1308
+ }
1309
+
1310
1310
  if (this.check([0x49, 0x49, 0x55, 0x00, 0x18, 0x00, 0x00, 0x00, 0x88, 0xE7, 0x74, 0xD8])) {
1311
1311
  return {
1312
1312
  ext: 'rw2',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-type",
3
- "version": "20.0.1",
3
+ "version": "20.1.0",
4
4
  "description": "Detect the file type of a file, stream, or data",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",
package/readme.md CHANGED
@@ -20,6 +20,8 @@ npm install file-type
20
20
 
21
21
  If you use it with Webpack, you need the latest Webpack version and ensure you configure it correctly for ESM.
22
22
 
23
+ File type detection is based on binary signatures (magic numbers) and should be treated as a best-effort hint, not a guarantee.
24
+
23
25
  ## Usage
24
26
 
25
27
  ### Node.js