file-type 19.4.1 → 19.5.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
@@ -165,6 +165,7 @@ export type FileExtension =
165
165
  | 'icc'
166
166
  | 'fbx'
167
167
  | 'vsdx'
168
+ | 'vtt'
168
169
  ; // eslint-disable-line semi-style
169
170
 
170
171
  export type MimeType =
@@ -270,6 +271,7 @@ export type MimeType =
270
271
  | 'audio/x-musepack'
271
272
  | 'text/calendar'
272
273
  | 'text/vcard'
274
+ | 'text/vtt'
273
275
  | 'model/gltf-binary'
274
276
  | 'application/vnd.tcpdump.pcap'
275
277
  | 'audio/x-dsf' // Non-standard
package/core.js CHANGED
@@ -1139,6 +1139,18 @@ export class FileTypeParser {
1139
1139
  }
1140
1140
  }
1141
1141
 
1142
+ if (
1143
+ this.checkString('WEBVTT')
1144
+ && (
1145
+ // One of LF, CR, tab, space, or end of file must follow "WEBVTT" per the spec (see `fixture/fixture-vtt-*.vtt` for examples). Note that `\0` is technically the null character (there is no such thing as an EOF character). However, checking for `\0` gives us the same result as checking for the end of the stream.
1146
+ (['\n', '\r', '\t', ' ', '\0'].some(char7 => this.checkString(char7, {offset: 6}))))
1147
+ ) {
1148
+ return {
1149
+ ext: 'vtt',
1150
+ mime: 'text/vtt',
1151
+ };
1152
+ }
1153
+
1142
1154
  // -- 8-byte signatures --
1143
1155
 
1144
1156
  if (this.check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "file-type",
3
- "version": "19.4.1",
3
+ "version": "19.5.0",
4
4
  "description": "Detect the file type of a file, stream, or data",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",
@@ -215,7 +215,8 @@
215
215
  "avro",
216
216
  "icc",
217
217
  "fbx",
218
- "vsdx"
218
+ "vsdx",
219
+ "vtt"
219
220
  ],
220
221
  "dependencies": {
221
222
  "get-stream": "^9.0.1",
package/readme.md CHANGED
@@ -507,6 +507,7 @@ console.log(fileType);
507
507
  - [`vcf`](https://en.wikipedia.org/wiki/VCard) - vCard
508
508
  - [`voc`](https://wiki.multimedia.cx/index.php/Creative_Voice) - Creative Voice File
509
509
  - [`vsdx`](https://en.wikipedia.org/wiki/Microsoft_Visio) - Microsoft Visio File
510
+ - [`vtt`](https://en.wikipedia.org/wiki/WebVTT) - WebVTT File (for video captions)
510
511
  - [`wasm`](https://en.wikipedia.org/wiki/WebAssembly) - WebAssembly intermediate compiled format
511
512
  - [`wav`](https://en.wikipedia.org/wiki/WAV) - Waveform Audio file
512
513
  - [`webm`](https://en.wikipedia.org/wiki/WebM) - Web video file
package/supported.js CHANGED
@@ -152,6 +152,7 @@ export const extensions = [
152
152
  'icc',
153
153
  'fbx',
154
154
  'vsdx',
155
+ 'vtt',
155
156
  ];
156
157
 
157
158
  export const mimeTypes = [
@@ -257,6 +258,7 @@ export const mimeTypes = [
257
258
  'audio/x-musepack',
258
259
  'text/calendar',
259
260
  'text/vcard',
261
+ 'text/vtt',
260
262
  'model/gltf-binary',
261
263
  'application/vnd.tcpdump.pcap',
262
264
  'audio/x-dsf', // Non-standard