1 | # Installation
|
2 | > `npm install --save @types/media-typer`
|
3 |
|
4 | # Summary
|
5 | This package contains type definitions for media-typer (https://github.com/jshttp/media-typer).
|
6 |
|
7 | # Details
|
8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/media-typer.
|
9 | ## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/media-typer/index.d.ts)
|
10 | ````ts
|
11 | // Type definitions for media-typer 1.1
|
12 | // Project: https://github.com/jshttp/media-typer
|
13 | // Definitions by: BendingBender <https://github.com/BendingBender>
|
14 | // Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
15 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
16 |
|
17 | /**
|
18 | * Simple RFC 6838 media type parser.
|
19 | * This module will parse a given media type into its component parts, like type, subtype, and suffix.
|
20 | * A formatter is also provided to put them back together and the two can be combined to normalize media types into a canonical form.
|
21 | * 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
|
22 | */
|
23 |
|
24 | /**
|
25 | * Parse a media type string
|
26 | * @throws TypeError If the given type string is invalid
|
27 | */
|
28 | export function parse(mediaType: string): MediaType;
|
29 | /**
|
30 | * Format an object into a media type string.
|
31 | * This will return a string of the mime type for the given object
|
32 | * @throws TypeError If any of the given object values are invalid
|
33 | */
|
34 | export function format(mediaTypeDescriptor: MediaType): string;
|
35 |
|
36 | /**
|
37 | * Validate a media type string
|
38 | */
|
39 | export function test(mediaType: string): boolean;
|
40 |
|
41 | export interface MediaType {
|
42 | /**
|
43 | * The type of the media type (always lower case). Example: `image`
|
44 | */
|
45 | type: string;
|
46 | /**
|
47 | * The subtype of the media type (always lower case). Example: `svg`
|
48 | */
|
49 | subtype: string;
|
50 | /**
|
51 | * The suffix of the media type (always lower case). Example: `xml`
|
52 | */
|
53 | suffix?: string | undefined;
|
54 | }
|
55 |
|
56 | ````
|
57 |
|
58 | ### Additional Details
|
59 | * Last updated: Tue, 06 Jul 2021 22:03:03 GMT
|
60 | * Dependencies: none
|
61 | * Global values: none
|
62 |
|
63 | # Credits
|
64 | These definitions were written by [BendingBender](https://github.com/BendingBender), and [Piotr Błażejewicz](https://github.com/peterblazejewicz).
|
65 |
|
\ | No newline at end of file |