@alshdavid/mime-types
Version:
The ultimate javascript content-type utility.
33 lines (32 loc) • 1.26 kB
TypeScript
/**
* @description
* Lookup the content-type associated with a file.
* @param path
* e.g. 'json', '.md', 'file.html', 'folder/file.js'
*/
export declare function lookup(path: string): [contentType: string, found: boolean];
/**
* @description
* Create a full content-type header given a content-type or extension.
* When given an extension, mime.lookup is used to get the matching content-type,
* otherwise the given content-type is used. Then if the content-type does not
* already have a charset parameter, mime.charset is used to get the default
* charset and add to the returned content-type.
* @param query
* e.g. 'markdown', 'file.json', 'text/html', 'text/html; charset=iso-8859-1'
*/
export declare function contentType(query: string): [contentType: string, found: boolean];
/**
* @description
* Get the default extension for a content-type.
* @param mimeType
* e.g. extension('application/octet-stream') -> 'bin'
*/
export declare function extension(mimeType: string): [extension: string, found: boolean];
/**
* @description
* Lookup the implied default charset of a content-type.
* @param mimeType
* e.g. charset('text/markdown') -> 'UTF-8'
*/
export declare function charset(mimeType: string): [charset: string, found: boolean];