Build 545032stable
Module 794268
1,021 characters · in 5156baf5d166b612.jsDependencies
Source Raw
function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.detectFile=void 0;let i=n(835986),r=n(817762);t.detectFile=function(e,t){var n;if(t&&Object.prototype.hasOwnProperty.call(t,"chunkSize")&&(null!=(n=null==t?void 0:t.chunkSize)?n:0)<=0)throw RangeError("chunkSize must be bigger than zero");let o=(0,r.getFileChunk)(e,(null==t?void 0:t.chunkSize)||64);if(0===o.length)return;let a=[],s=[];for(let e in i.FileTypes)if(Object.prototype.hasOwnProperty.call(i.FileTypes,e)){let t=i.FileTypes.getSignaturesByName(e),n=i.FileTypes.detectbBySignatures(o,t);if(n){let t=i.FileTypes.getInfoByName(e);i.FILE_TYPES_REQUIRED_ADDITIONAL_CHECK.includes(t.extension)&&s.push(t.extension);let r={extension:t.extension,mimeType:t.mimeType,description:t.description,signature:Object.assign(Object.assign({},n),{sequence:n.sequence.map(e=>e.toString(16))})};a.push(r)}}if(0===a.length)return;if(1===a.length&&0===s.length)return a[0];let l=i.FileTypes.detectTypeByAdditionalCheck(o,a);if(l)return a.find(e=>e.extension===l)}}