file-type 15.0.0 → 16.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.
package/core.d.ts CHANGED
@@ -37,7 +37,6 @@ declare namespace core {
37
37
  | 'webm'
38
38
  | 'mov'
39
39
  | 'avi'
40
- | 'wmv'
41
40
  | 'mpg'
42
41
  | 'mp2'
43
42
  | 'mp3'
@@ -99,7 +98,6 @@ declare namespace core {
99
98
  | 'ape'
100
99
  | 'wv'
101
100
  | 'asf'
102
- | 'wma'
103
101
  | 'dcm'
104
102
  | 'mpc'
105
103
  | 'ics'
@@ -136,7 +134,9 @@ declare namespace core {
136
134
  | 'eps'
137
135
  | 'lzh'
138
136
  | 'pgp'
139
- | 'asar';
137
+ | 'asar'
138
+ | 'stl'
139
+ | 'chm';
140
140
 
141
141
  type MimeType =
142
142
  | 'image/jpeg'
@@ -175,7 +175,7 @@ declare namespace core {
175
175
  | 'video/vnd.avi'
176
176
  | 'audio/vnd.wave'
177
177
  | 'audio/qcelp'
178
- | 'audio/x-ms-wma'
178
+ | 'audio/x-ms-asf'
179
179
  | 'video/x-ms-asf'
180
180
  | 'application/vnd.ms-asf'
181
181
  | 'video/mpeg'
@@ -264,7 +264,9 @@ declare namespace core {
264
264
  | 'image/avif'
265
265
  | 'application/x-lzh-compressed'
266
266
  | 'application/pgp-encrypted'
267
- | 'application/x-asar';
267
+ | 'application/x-asar'
268
+ | 'model/stl'
269
+ | 'application/vnd.ms-htmlhelp';
268
270
 
269
271
  interface FileTypeResult {
270
272
  /**
package/core.js CHANGED
@@ -880,6 +880,13 @@ async function _fromTokenizer(tokenizer) {
880
880
  }
881
881
  }
882
882
 
883
+ if (checkString('ITSF')) {
884
+ return {
885
+ ext: 'chm',
886
+ mime: 'application/vnd.ms-htmlhelp'
887
+ };
888
+ }
889
+
883
890
  // -- 6-byte signatures --
884
891
 
885
892
  if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
@@ -920,6 +927,13 @@ async function _fromTokenizer(tokenizer) {
920
927
  };
921
928
  }
922
929
 
930
+ if (checkString('solid ')) {
931
+ return {
932
+ ext: 'stl',
933
+ mime: 'model/stl'
934
+ };
935
+ }
936
+
923
937
  // -- 7-byte signatures --
924
938
 
925
939
  if (checkString('BLENDER')) {
@@ -967,6 +981,10 @@ async function _fromTokenizer(tokenizer) {
967
981
 
968
982
  do {
969
983
  const chunk = await readChunkHeader();
984
+ if (chunk.length < 0) {
985
+ return; // Invalid chunk length
986
+ }
987
+
970
988
  switch (chunk.type) {
971
989
  case 'IDAT':
972
990
  return {
@@ -981,7 +999,7 @@ async function _fromTokenizer(tokenizer) {
981
999
  default:
982
1000
  await tokenizer.ignore(chunk.length + 4); // Ignore chunk-data + CRC
983
1001
  }
984
- } while (tokenizer.position < tokenizer.fileInfo.size);
1002
+ } while (tokenizer.position + 8 < tokenizer.fileInfo.size);
985
1003
 
986
1004
  return {
987
1005
  ext: 'png',
@@ -1058,15 +1076,15 @@ async function _fromTokenizer(tokenizer) {
1058
1076
  if (_check(typeId, [0x40, 0x9E, 0x69, 0xF8, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B])) {
1059
1077
  // Found audio:
1060
1078
  return {
1061
- ext: 'wma',
1062
- mime: 'audio/x-ms-wma'
1079
+ ext: 'asf',
1080
+ mime: 'audio/x-ms-asf'
1063
1081
  };
1064
1082
  }
1065
1083
 
1066
1084
  if (_check(typeId, [0xC0, 0xEF, 0x19, 0xBC, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B])) {
1067
1085
  // Found video:
1068
1086
  return {
1069
- ext: 'wmv',
1087
+ ext: 'asf',
1070
1088
  mime: 'video/x-ms-asf'
1071
1089
  };
1072
1090
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-type",
3
- "version": "15.0.0",
3
+ "version": "16.1.0",
4
4
  "description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",
@@ -31,6 +31,7 @@
31
31
  "mime",
32
32
  "file",
33
33
  "type",
34
+ "magic",
34
35
  "archive",
35
36
  "image",
36
37
  "img",
@@ -132,7 +133,6 @@
132
133
  "odp",
133
134
  "xml",
134
135
  "heic",
135
- "wma",
136
136
  "ics",
137
137
  "glb",
138
138
  "pcap",
@@ -151,7 +151,6 @@
151
151
  "f4v",
152
152
  "mie",
153
153
  "qcp",
154
- "wmv",
155
154
  "asf",
156
155
  "ogv",
157
156
  "ogm",
@@ -179,7 +178,9 @@
179
178
  "eps",
180
179
  "lzh",
181
180
  "pgp",
182
- "asar"
181
+ "asar",
182
+ "stl",
183
+ "chm"
183
184
  ],
184
185
  "devDependencies": {
185
186
  "@types/node": "^13.1.4",
@@ -190,7 +191,7 @@
190
191
  "xo": "^0.25.3"
191
192
  },
192
193
  "dependencies": {
193
- "readable-web-to-node-stream": "^2.0.0",
194
+ "readable-web-to-node-stream": "^3.0.0",
194
195
  "strtok3": "^6.0.3",
195
196
  "token-types": "^2.0.0",
196
197
  "typedarray-to-buffer": "^3.1.5"
package/readme.md CHANGED
@@ -1,9 +1,11 @@
1
- # file-type [![Build Status](https://travis-ci.com/sindresorhus/file-type.svg?branch=master)](https://travis-ci.com/github/sindresorhus/file-type)
1
+ # file-type
2
2
 
3
3
  > Detect the file type of a Buffer/Uint8Array/ArrayBuffer
4
4
 
5
5
  The file type is detected by checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.
6
6
 
7
+ This package is for detecting binary-based file formats, not text-based formats like `.txt`, `.csv`, `.svg`, etc.
8
+
7
9
  ## Install
8
10
 
9
11
  ```
@@ -367,8 +369,6 @@ Returns a set of supported MIME types.
367
369
  - [`ape`](https://en.wikipedia.org/wiki/Monkey%27s_Audio) - Monkey's Audio
368
370
  - [`wv`](https://en.wikipedia.org/wiki/WavPack) - WavPack
369
371
  - [`asf`](https://en.wikipedia.org/wiki/Advanced_Systems_Format) - Advanced Systems Format
370
- - [`wma`](https://en.wikipedia.org/wiki/Windows_Media_Audio) - Windows Media Audio
371
- - [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video) - Windows Media Video
372
372
  - [`dcm`](https://en.wikipedia.org/wiki/DICOM#Data_format) - DICOM Image File
373
373
  - [`mpc`](https://en.wikipedia.org/wiki/Musepack) - Musepack (SV7 & SV8)
374
374
  - [`ics`](https://en.wikipedia.org/wiki/ICalendar#Data_format) - iCalendar
@@ -403,13 +403,15 @@ Returns a set of supported MIME types.
403
403
  - [`lzh`](https://en.wikipedia.org/wiki/LHA_(file_format)) - LZH archive
404
404
  - [`pgp`](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) - Pretty Good Privacy
405
405
  - [`asar`](https://github.com/electron/asar#format) - Archive format primarily used to enclose Electron applications
406
+ - [`stl`](https://en.wikipedia.org/wiki/STL_(file_format)) - Standard Tesselated Geometry File Format (ASCII only)
407
+ - [`chm`](https://en.wikipedia.org/wiki/Microsoft_Compiled_HTML_Help) - Microsoft Compiled HTML Help
406
408
 
407
409
  *Pull requests are welcome for additional commonly used file types.*
408
410
 
409
411
  The following file types will not be accepted:
410
412
  - [MS-CFB: Microsoft Compound File Binary File Format based formats](https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/53989ce4-7b05-4f8d-829b-d08d6148375b), too old and difficult to parse:
411
- - `.doc` - Microsoft Word 97-2003 Document
412
- - `.xls` - Microsoft Excel 97-2003 Document
413
+ - `.doc` - Microsoft Word 97-2003 Document
414
+ - `.xls` - Microsoft Excel 97-2003 Document
413
415
  - `.ppt` - Microsoft PowerPoint97-2003 Document
414
416
  - `.msi` - Microsoft Windows Installer
415
417
  - `.csv` - [Reason.](https://github.com/sindresorhus/file-type/issues/264#issuecomment-568439196)
package/supported.js CHANGED
@@ -98,8 +98,6 @@ module.exports = {
98
98
  'ktx',
99
99
  'ape',
100
100
  'wv',
101
- 'wmv',
102
- 'wma',
103
101
  'dcm',
104
102
  'ics',
105
103
  'glb',
@@ -134,7 +132,9 @@ module.exports = {
134
132
  'eps',
135
133
  'lzh',
136
134
  'pgp',
137
- 'asar'
135
+ 'asar',
136
+ 'stl',
137
+ 'chm'
138
138
  ],
139
139
  mimeTypes: [
140
140
  'image/jpeg',
@@ -173,7 +173,7 @@ module.exports = {
173
173
  'video/vnd.avi',
174
174
  'audio/vnd.wave',
175
175
  'audio/qcelp',
176
- 'audio/x-ms-wma',
176
+ 'audio/x-ms-asf',
177
177
  'video/x-ms-asf',
178
178
  'application/vnd.ms-asf',
179
179
  'video/mpeg',
@@ -262,6 +262,8 @@ module.exports = {
262
262
  'image/avif',
263
263
  'application/x-lzh-compressed',
264
264
  'application/pgp-encrypted',
265
- 'application/x-asar'
265
+ 'application/x-asar',
266
+ 'model/stl',
267
+ 'application/vnd.ms-htmlhelp'
266
268
  ]
267
269
  };