Files
discord-decomp/_bundle/Module4773.js
T
2026-11-01 12:12:55 +02:00

47 lines
1.6 KiB
JavaScript

// Metro module 4773 (f4774).
import { getFileChunk } from "./fetchFromObject";
import { FileTypes, FILE_TYPES_REQUIRED_ADDITIONAL_CHECK } from "./Module4775";
export function detectFile(a0, a1) {
if (a1 && Object.prototype.hasOwnProperty.call(a1, "chunkSize")) {
const chunkSize = a1?.chunkSize;
if ((chunkSize !== null ? chunkSize !== void 0 ? chunkSize : 0 : 0) <= 0) {
throw new RangeError("chunkSize must be bigger than zero");
}
}
const fileChunk = getFileChunk(a0, a1?.chunkSize || 64);
if (fileChunk.length !== 0) {
const r44 = [];
const r45 = [];
for (const key in FileTypes) {
if (Object.prototype.hasOwnProperty.call(FileTypes, key)) {
const r64 = FileTypes.detectbBySignatures(fileChunk, FileTypes.getSignaturesByName(key));
if (r64) {
const infoByName = FileTypes.getInfoByName(key);
if (FILE_TYPES_REQUIRED_ADDITIONAL_CHECK.includes(infoByName.extension)) {
r45.push(infoByName.extension);
}
r44.push({
extension: infoByName.extension,
mimeType: infoByName.mimeType,
description: infoByName.description,
signature: {
...r64,
sequence: r64.sequence.map((item) => item.toString(16))
}
});
}
}
}
if (r44.length !== 0) {
if (r44.length === 1 && r45.length === 0) {
return r44[0];
}
const r106 = FileTypes.detectTypeByAdditionalCheck(fileChunk, r44);
let c14428_0 = r106;
if (r106) {
return r44.find((item) => item.extension === c14428_0);
}
}
}
}