file-type 18.1.0 → 18.2.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
@@ -143,7 +143,8 @@ export type FileExtension =
143
143
  | 'vcf'
144
144
  | 'jls'
145
145
  | 'pst'
146
- | 'dwg';
146
+ | 'dwg'
147
+ | 'parquet';
147
148
 
148
149
  export type MimeType =
149
150
  | 'image/jpeg'
@@ -282,7 +283,8 @@ export type MimeType =
282
283
  | 'application/zstd'
283
284
  | 'image/jls'
284
285
  | 'application/vnd.ms-outlook'
285
- | 'image/vnd.dwg';
286
+ | 'image/vnd.dwg'
287
+ | 'application/x-parquet';
286
288
 
287
289
  export type FileTypeResult = {
288
290
  /**
package/core.js CHANGED
@@ -611,17 +611,24 @@ class FileTypeParser {
611
611
  }
612
612
 
613
613
  if (this.checkString('%PDF')) {
614
- await tokenizer.ignore(1350);
615
- const maxBufferSize = 10 * 1024 * 1024;
616
- const buffer = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size));
617
- await tokenizer.readBuffer(buffer, {mayBeLess: true});
614
+ try {
615
+ await tokenizer.ignore(1350);
616
+ const maxBufferSize = 10 * 1024 * 1024;
617
+ const buffer = Buffer.alloc(Math.min(maxBufferSize, tokenizer.fileInfo.size));
618
+ await tokenizer.readBuffer(buffer, {mayBeLess: true});
618
619
 
619
- // Check if this is an Adobe Illustrator file
620
- if (buffer.includes(Buffer.from('AIPrivateData'))) {
621
- return {
622
- ext: 'ai',
623
- mime: 'application/postscript',
624
- };
620
+ // Check if this is an Adobe Illustrator file
621
+ if (buffer.includes(Buffer.from('AIPrivateData'))) {
622
+ return {
623
+ ext: 'ai',
624
+ mime: 'application/postscript',
625
+ };
626
+ }
627
+ } catch (error) {
628
+ // Swallow end of stream error if file is too small for the Adobe AI check
629
+ if (!(error instanceof strtok3.EndOfStreamError)) {
630
+ throw error;
631
+ }
625
632
  }
626
633
 
627
634
  // Assume this is just a normal PDF
@@ -815,6 +822,13 @@ class FileTypeParser {
815
822
  };
816
823
  }
817
824
 
825
+ if (this.checkString('PAR1')) {
826
+ return {
827
+ ext: 'parquet',
828
+ mime: 'application/x-parquet',
829
+ };
830
+ }
831
+
818
832
  // -- 5-byte signatures --
819
833
 
820
834
  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": "18.1.0",
3
+ "version": "18.2.1",
4
4
  "description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer",
5
5
  "license": "MIT",
6
6
  "repository": "sindresorhus/file-type",
@@ -196,7 +196,8 @@
196
196
  "vcf",
197
197
  "jls",
198
198
  "pst",
199
- "dwg"
199
+ "dwg",
200
+ "parquet"
200
201
  ],
201
202
  "dependencies": {
202
203
  "readable-web-to-node-stream": "^3.0.2",
package/readme.md CHANGED
@@ -440,6 +440,7 @@ Returns a `Set<string>` of supported MIME types.
440
440
  - [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format)) - Audio file
441
441
  - [`orf`](https://en.wikipedia.org/wiki/ORF_format) - Olympus Raw image file
442
442
  - [`otf`](https://en.wikipedia.org/wiki/OpenType) - OpenType font
443
+ - [`parquet`](https://en.wikipedia.org/wiki/Apache_Parquet) - Apache Parquet
443
444
  - [`pcap`](https://wiki.wireshark.org/Development/LibpcapFileFormat) - Libpcap File Format
444
445
  - [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format) - Portable Document Format
445
446
  - [`pgp`](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) - Pretty Good Privacy
package/supported.js CHANGED
@@ -141,6 +141,7 @@ export const extensions = [
141
141
  'jls',
142
142
  'pst',
143
143
  'dwg',
144
+ 'parquet',
144
145
  ];
145
146
 
146
147
  export const mimeTypes = [
@@ -281,4 +282,5 @@ export const mimeTypes = [
281
282
  'image/jls',
282
283
  'application/vnd.ms-outlook',
283
284
  'image/vnd.dwg',
285
+ 'application/x-parquet',
284
286
  ];