file-type 3.4.0 → 3.8.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/index.js +36 -2
  2. package/package.json +5 -2
  3. package/readme.md +56 -53
package/index.js CHANGED
@@ -218,6 +218,14 @@ module.exports = function (buf) {
218
218
  };
219
219
  }
220
220
 
221
+ // needs to be before `ogg` check
222
+ if (buf[28] === 0x4F && buf[29] === 0x70 && buf[30] === 0x75 && buf[31] === 0x73 && buf[32] === 0x48 && buf[33] === 0x65 && buf[34] === 0x61 && buf[35] === 0x64) {
223
+ return {
224
+ ext: 'opus',
225
+ mime: 'audio/opus'
226
+ };
227
+ }
228
+
221
229
  if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
222
230
  return {
223
231
  ext: 'ogg',
@@ -274,14 +282,26 @@ module.exports = function (buf) {
274
282
  };
275
283
  }
276
284
 
277
- if (buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x46 && buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) {
285
+ if (
286
+ (buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x46) &&
287
+ (
288
+ (buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
289
+ (buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
290
+ )
291
+ ) {
278
292
  return {
279
293
  ext: 'woff',
280
294
  mime: 'application/font-woff'
281
295
  };
282
296
  }
283
297
 
284
- if (buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x32 && buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) {
298
+ if (
299
+ (buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x32) &&
300
+ (
301
+ (buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
302
+ (buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
303
+ )
304
+ ) {
285
305
  return {
286
306
  ext: 'woff2',
287
307
  mime: 'application/font-woff'
@@ -390,6 +410,13 @@ module.exports = function (buf) {
390
410
  };
391
411
  }
392
412
 
413
+ if (buf[0] === 0xED && buf[1] === 0xAB && buf[2] === 0xEE && buf[3] === 0xDB) {
414
+ return {
415
+ ext: 'rpm',
416
+ mime: 'application/x-rpm'
417
+ };
418
+ }
419
+
393
420
  if (
394
421
  (buf[0] === 0x1F && buf[1] === 0xA0) ||
395
422
  (buf[0] === 0x1F && buf[1] === 0x9D)
@@ -407,5 +434,12 @@ module.exports = function (buf) {
407
434
  };
408
435
  }
409
436
 
437
+ if (buf[0] === 0xD0 && buf[1] === 0xCF && buf[2] === 0x11 && buf[3] === 0xE0 && buf[4] === 0xA1 && buf[5] === 0xB1 && buf[6] === 0x1A && buf[7] === 0xE1) {
438
+ return {
439
+ ext: 'msi',
440
+ mime: 'application/x-msi'
441
+ };
442
+ }
443
+
410
444
  return null;
411
445
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-type",
3
- "version": "3.4.0",
3
+ "version": "3.8.0",
4
4
  "description": "Detect the file type of a Buffer/Uint8Array",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",
@@ -66,6 +66,7 @@
66
66
  "mp3",
67
67
  "m4a",
68
68
  "ogg",
69
+ "opus",
69
70
  "flac",
70
71
  "wav",
71
72
  "amr",
@@ -88,8 +89,10 @@
88
89
  "cab",
89
90
  "deb",
90
91
  "ar",
92
+ "rpm",
91
93
  "Z",
92
- "lz"
94
+ "lz",
95
+ "msi"
93
96
  ],
94
97
  "devDependencies": {
95
98
  "ava": "*",
package/readme.md CHANGED
@@ -75,60 +75,63 @@ It only needs the first 262 bytes.
75
75
 
76
76
  ## Supported file types
77
77
 
78
- - `jpg`
79
- - `png`
80
- - `gif`
81
- - `webp`
82
- - `cr2`
83
- - `tif`
84
- - `bmp`
85
- - `jxr`
86
- - `psd`
87
- - `zip`
88
- - `tar`
89
- - `rar`
90
- - `gz`
91
- - `bz2`
92
- - `7z`
93
- - `dmg`
94
- - `mp4`
95
- - `m4v`
96
- - `mid`
97
- - `mkv`
98
- - `webm`
99
- - `mov`
100
- - `avi`
101
- - `wmv`
102
- - `mpg`
103
- - `mp3`
104
- - `m4a`
105
- - `ogg`
106
- - `flac`
107
- - `wav`
78
+ - [`jpg`](https://en.wikipedia.org/wiki/JPEG)
79
+ - [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics)
80
+ - [`gif`](https://en.wikipedia.org/wiki/GIF)
81
+ - [`webp`](https://en.wikipedia.org/wiki/WebP)
82
+ - [`cr2`](http://fileinfo.com/extension/cr2)
83
+ - [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format)
84
+ - [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format)
85
+ - [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
86
+ - [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
87
+ - [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format))
88
+ - [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format)
89
+ - [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format))
90
+ - [`gz`](https://en.wikipedia.org/wiki/Gzip)
91
+ - [`bz2`](https://en.wikipedia.org/wiki/Bzip2)
92
+ - [`7z`](https://en.wikipedia.org/wiki/7z)
93
+ - [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image)
94
+ - [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions)
95
+ - [`m4v`](https://en.wikipedia.org/wiki/M4V)
96
+ - [`mid`](https://en.wikipedia.org/wiki/MIDI)
97
+ - [`mkv`](https://en.wikipedia.org/wiki/Matroska)
98
+ - [`webm`](https://en.wikipedia.org/wiki/WebM)
99
+ - [`mov`](https://en.wikipedia.org/wiki/QuickTime_File_Format)
100
+ - [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave)
101
+ - [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video)
102
+ - [`mpg`](https://en.wikipedia.org/wiki/MPEG-1)
103
+ - [`mp3`](https://en.wikipedia.org/wiki/MP3)
104
+ - [`m4a`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#.MP4_versus_.M4A)
105
+ - [`ogg`](https://en.wikipedia.org/wiki/Ogg)
106
+ - [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format))
107
+ - [`flac`](https://en.wikipedia.org/wiki/FLAC)
108
+ - [`wav`](https://en.wikipedia.org/wiki/WAV)
108
109
  - [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec)
109
- - `pdf`
110
- - `epub`
111
- - `exe`
112
- - `swf`
113
- - `rtf`
114
- - `woff`
115
- - `woff2`
116
- - `eot`
117
- - `ttf`
118
- - `otf`
119
- - `ico`
120
- - `flv`
121
- - `ps`
122
- - `xz`
123
- - `sqlite`
124
- - `nes`
125
- - `crx`
126
- - `xpi`
127
- - `cab`
128
- - `deb`
129
- - `ar`
130
- - `Z`
131
- - `lz`
110
+ - [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format)
111
+ - [`epub`](https://en.wikipedia.org/wiki/EPUB)
112
+ - [`exe`](https://en.wikipedia.org/wiki/.exe)
113
+ - [`swf`](https://en.wikipedia.org/wiki/SWF)
114
+ - [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format)
115
+ - [`woff`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
116
+ - [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
117
+ - [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType)
118
+ - [`ttf`](https://en.wikipedia.org/wiki/TrueType)
119
+ - [`otf`](https://en.wikipedia.org/wiki/OpenType)
120
+ - [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format))
121
+ - [`flv`](https://en.wikipedia.org/wiki/Flash_Video)
122
+ - [`ps`](https://en.wikipedia.org/wiki/Postscript)
123
+ - [`xz`](https://en.wikipedia.org/wiki/Xz)
124
+ - [`sqlite`](https://www.sqlite.org/fileformat2.html)
125
+ - [`nes`](http://fileinfo.com/extension/nes)
126
+ - [`crx`](https://developer.chrome.com/extensions/crx)
127
+ - [`xpi`](https://en.wikipedia.org/wiki/XPInstall)
128
+ - [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format))
129
+ - [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format))
130
+ - [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix))
131
+ - [`rpm`](http://fileinfo.com/extension/rpm)
132
+ - [`Z`](http://fileinfo.com/extension/z)
133
+ - [`lz`](https://en.wikipedia.org/wiki/Lzip)
134
+ - [`msi`](https://en.wikipedia.org/wiki/Windows_Installer)
132
135
 
133
136
  *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).*
134
137