UNPKG

astro

Version:

Astro is a modern site builder with web best practices, performance, and DX front-of-mind.

27 lines (26 loc) 673 B
import { typeHandlers } from "./types/index.js"; import { detector } from "./detector.js"; const globalOptions = { disabledTypes: [] }; function lookup(input) { const type = detector(input); if (typeof type !== "undefined") { if (globalOptions.disabledTypes.includes(type)) { throw new TypeError("disabled file type: " + type); } const size = typeHandlers.get(type).calculate(input); if (size !== void 0) { size.type = size.type ?? type; return size; } } throw new TypeError("unsupported file type: " + type); } const disableTypes = (types) => { globalOptions.disabledTypes = types; }; export { disableTypes, lookup };