astro-ghostcms/.pnpm-store/v3/files/34/ede7ee7f4589dfda07ac2432318...

25 lines
531 B
Plaintext
Raw Normal View History

2024-02-20 00:35:26 +00:00
import { typeHandlers, types } from "./types/index.js";
const firstBytes = /* @__PURE__ */ new Map([
[56, "psd"],
[66, "bmp"],
[68, "dds"],
[71, "gif"],
[73, "tiff"],
[77, "tiff"],
[82, "webp"],
[105, "icns"],
[137, "png"],
[255, "jpg"]
]);
function detector(input) {
const byte = input[0];
const type = firstBytes.get(byte);
if (type && typeHandlers.get(type).validate(input)) {
return type;
}
return types.find((fileType) => typeHandlers.get(fileType).validate(input));
}
export {
detector
};