file-type
Advanced tools
Comparing version 14.0.0 to 14.1.0
@@ -130,3 +130,4 @@ /// <reference types="node"/> | ||
| 's3m' | ||
| 'xm'; | ||
| 'xm' | ||
| 'ai'; | ||
@@ -249,3 +250,5 @@ type MimeType = | ||
| 'audio/x-s3m' | ||
| 'audio/x-xm'; | ||
| 'audio/x-xm' | ||
| 'video/MP1S' | ||
| 'video/MP2P'; | ||
@@ -252,0 +255,0 @@ interface FileTypeResult { |
39
core.js
@@ -59,2 +59,11 @@ 'use strict'; | ||
async function _checkSequence(sequence, tokenizer, ignoreBytes) { | ||
const buffer = Buffer.alloc(minimumBytes); | ||
await tokenizer.ignore(ignoreBytes); | ||
await tokenizer.peekBuffer(buffer, {length: 512, mayBeLess: true}); | ||
return buffer.includes(Buffer.from(sequence)); | ||
} | ||
async function fromTokenizer(tokenizer) { | ||
@@ -75,2 +84,3 @@ try { | ||
const checkString = (header, options) => check(stringToBytes(header), options); | ||
const checkSequence = (sequence, ignoreBytes) => _checkSequence(sequence, tokenizer, ignoreBytes); | ||
@@ -553,2 +563,12 @@ // Keep reading until EOF if the file size is unknown. | ||
if (checkString('%PDF')) { | ||
// Check if this is an Adobe Illustrator file | ||
const isAiFile = await checkSequence('Adobe Illustrator', 1350); | ||
if (isAiFile) { | ||
return { | ||
ext: 'ai', | ||
mime: 'application/postscript' | ||
}; | ||
} | ||
// Assume this is just a normal PDF | ||
return { | ||
@@ -789,2 +809,21 @@ ext: 'pdf', | ||
// MPEG program stream (PS or MPEG-PS) | ||
if (check([0x00, 0x00, 0x01, 0xBA])) { | ||
// MPEG-PS, MPEG-1 Part 1 | ||
if (check([0x21], {offset: 4, mask: [0xF1]})) { | ||
return { | ||
ext: 'mpg', // May also be .ps, .mpeg | ||
mime: 'video/MP1S' | ||
}; | ||
} | ||
// MPEG-PS, MPEG-2 Part 1 | ||
if (check([0x44], {offset: 4, mask: [0xC4]})) { | ||
return { | ||
ext: 'mpg', // May also be .mpg, .m2p, .vob or .sub | ||
mime: 'video/MP2P' | ||
}; | ||
} | ||
} | ||
// -- 6-byte signatures -- | ||
@@ -791,0 +830,0 @@ |
{ | ||
"name": "file-type", | ||
"version": "14.0.0", | ||
"version": "14.1.0", | ||
"description": "Detect the file type of a Buffer/Uint8Array/ArrayBuffer", | ||
@@ -173,3 +173,4 @@ "license": "MIT", | ||
"s3m", | ||
"xm" | ||
"xm", | ||
"ai" | ||
], | ||
@@ -176,0 +177,0 @@ "devDependencies": { |
@@ -372,2 +372,3 @@ # file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type) | ||
- [`xm`](https://wiki.openmpt.org/Manual:_Module_formats#The_FastTracker_2_format_.28.xm.29) - Audio module format: FastTracker 2 | ||
- [`ai`](https://en.wikipedia.org/wiki/Adobe_Illustrator_Artwork) - Adobe Illustrator Artwork | ||
@@ -374,0 +375,0 @@ *Pull requests are welcome for additional commonly used file types.* |
@@ -128,3 +128,4 @@ 'use strict'; | ||
's3m', | ||
'xm' | ||
'xm', | ||
'ai' | ||
], | ||
@@ -247,4 +248,6 @@ mimeTypes: [ | ||
'audio/x-s3m', | ||
'audio/x-xm' | ||
'audio/x-xm', | ||
'video/MP1S', | ||
'video/MP2P' | ||
] | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68667
1898
399