@nasriya/mimex
Version:
A lightweight MIME type and file extension manager for Node.js and web applications. Mimex provides fast lookup, extension-to-MIME and MIME-to-extension resolution, and easy registration of custom types.
40 lines (39 loc) • 3.4 kB
TypeScript
import type { Mime, Extension } from "./mimeTypes";
declare class MimeX {
/**
* Retrieves the MIME type associated with the given file extension.
* @param extension - The file extension (with or without leading dot).
* @returns The MIME type associated with the given file extension, or undefined if not found.
*/
getMimes(extension: string): Readonly<Mime[]> | undefined;
/**
* Retrieves the file extensions associated with the given MIME type.
* @param mime - The MIME type.
* @returns The file extensions associated with the given MIME type, or undefined if not found.
*/
getExtensions(mime: string): Readonly<Extension[]> | undefined;
/**
* Checks if the given string is a valid MIME type supported by Mimex.
* @param mime - The MIME type to check.
* @returns True if the MIME type is supported, false otherwise.
*/
isMime(mime: string): boolean;
/**
* Checks if the given string is a valid file extension supported by Mimex.
* @param extension - The file extension to check.
* @returns True if the file extension is supported, false otherwise.
*/
isExtension(extension: string): boolean;
/**
* Retrieves the list of supported MIME types.
* @returns The list of supported MIME types.
*/
get mimes(): readonly ("image/webp" | "audio/aac" | "application/x-abiword" | "application/x-freearc" | "image/avif" | "video/x-msvideo" | "application/vnd.amazon.ebook" | "application/octet-stream" | "image/bmp" | "application/x-bzip" | "application/x-bzip2" | "application/x-cdf" | "application/x-csh" | "text/css" | "text/csv" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-fontobject" | "application/epub+zip" | "application/gzip" | "image/gif" | "text/html" | "image/vnd.microsoft.icon" | "text/calendar" | "application/java-archive" | "image/jpeg" | "text/javascript" | "application/json" | "application/ld+json" | "audio/midi" | "audio/x-midi" | "audio/mpeg" | "video/mp4" | "video/mpeg" | "application/vnd.apple.installer+xml" | "application/vnd.oasis.opendocument.presentation" | "application/vnd.oasis.opendocument.spreadsheet" | "application/vnd.oasis.opendocument.text" | "audio/ogg" | "video/ogg" | "application/ogg" | "audio/opus" | "font/otf" | "image/png" | "application/pdf" | "application/x-httpd-php" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.rar" | "application/rtf" | "application/x-sh" | "image/svg+xml" | "application/x-tar" | "image/tiff")[];
/**
* Retrieves the list of supported file extensions.
* @returns The list of supported file extensions.
*/
get extensions(): readonly (".webp" | ".aac" | ".abw" | ".arc" | ".avif" | ".avi" | ".azw" | ".bin" | ".bmp" | ".bz" | ".bz2" | ".cda" | ".csh" | ".css" | ".csv" | ".doc" | ".docx" | ".eot" | ".epub" | ".gz" | ".gif" | ".htm" | ".html" | ".ico" | ".ics" | ".jar" | ".jpeg" | ".jpg" | ".js" | ".json" | ".jsonld" | ".mid" | ".midi" | ".mjs" | ".mp3" | ".mp4" | ".mpeg" | ".mpkg" | ".odp" | ".ods" | ".odt" | ".oga" | ".ogv" | ".ogx" | ".opus" | ".otf" | ".png" | ".pdf" | ".php" | ".ppt" | ".pptx" | ".rar" | ".rtf" | ".sh" | ".svg" | ".tar" | ".tif" | ".tiff")[];
}
declare const mimex: MimeX;
export default mimex;