@thi.ng/mime
Version:
650+ file extension to MIME type mappings, based on mime-db
54 lines • 1.75 kB
TypeScript
export declare const MIME_TYPES: Record<string, string[]>;
/**
* Returns preferred MIME type for given file extension `ext`, or if no match is
* available, the `fallback` MIME type (default: `application/octet-stream`).
* `ext` is converted to lowercase first.
*
* @remarks
* Since v0.2.0 the extension can be given as either `".ext"` or `"ext"`.
* Previously, only the latter was supported.
*
* Also see {@link preferredExtension} for reverse operation.
*
* @param ext -
* @param fallback -
*/
export declare const preferredType: (ext: string, fallback?: string) => string;
/**
* Similar to {@link preferredType}, but accepts a file path and first
* auto-extracts file extension.
*
* @param path
* @param fallback
*/
export declare const preferredTypeForPath: (path: string, fallback?: string) => string;
/**
* Reverse lookup to {@link preferredType}. Takes MIME type string and returns
* preferred file extension (or failing that) returns `fallback` (default:
* "bin").
*
* @param mime -
* @param fallback -
*/
export declare const preferredExtension: (mime: string, fallback?: string) => string;
/**
* Returns all known file extensions for given MIME type or undefined if
* unknown.
*
* @param mime
*/
export declare const extensionsForType: (mime: string) => string[] | undefined;
/**
* Returns true if the given MIME type can be compressed (or served using
* gzip/brotli encoding).
*
* @remarks
* Note: Information here is included as is. Some of these judgements in the
* original mime-db project (or their sources of information) are highly
* questionable...
*
* @param mime
*/
export declare const isCompressible: (mime: string) => boolean;
export * from "./presets.js";
//# sourceMappingURL=index.d.ts.map