mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
* update(media-typer): version 1.1 - add new `test` method - missing docs comments - version bump to 1.1 - v0 created for compatibility - maintainer added https://github.com/jshttp/media-typer/compare/v0.3.0...v1.1.0 https://github.com/jshttp/media-typer#typerteststring Thanks! * Update types/media-typer/index.d.ts thx to @sandersn Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> * Update types/media-typer/index.d.ts thx to @sandersn Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
// Type definitions for media-typer 1.1
|
|
// Project: https://github.com/jshttp/media-typer
|
|
// Definitions by: BendingBender <https://github.com/BendingBender>
|
|
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
/**
|
|
* Simple RFC 6838 media type parser.
|
|
* This module will parse a given media type into its component parts, like type, subtype, and suffix.
|
|
* A formatter is also provided to put them back together and the two can be combined to normalize media types into a canonical form.
|
|
* If you are looking to parse the string that represents a media type and its parameters in HTTP (for example, the Content-Type header), use the content-type module
|
|
*/
|
|
|
|
/**
|
|
* Parse a media type string
|
|
* @throws TypeError If the given type string is invalid
|
|
*/
|
|
export function parse(mediaType: string): MediaType;
|
|
/**
|
|
* Format an object into a media type string.
|
|
* This will return a string of the mime type for the given object
|
|
* @throws TypeError If any of the given object values are invalid
|
|
*/
|
|
export function format(mediaTypeDescriptor: MediaType): string;
|
|
|
|
/**
|
|
* Validate a media type string
|
|
*/
|
|
export function test(mediaType: string): boolean;
|
|
|
|
export interface MediaType {
|
|
/**
|
|
* The type of the media type (always lower case). Example: `image`
|
|
*/
|
|
type: string;
|
|
/**
|
|
* The subtype of the media type (always lower case). Example: `svg`
|
|
*/
|
|
subtype: string;
|
|
/**
|
|
* The suffix of the media type (always lower case). Example: `xml`
|
|
*/
|
|
suffix?: string;
|
|
}
|