Parsing a MIME type
Examples
import MIMETypeParser from '@saekitominaga/mime-parser';
const mimeTypeParser = new MIMETypeParser('Text/HTML; Charset=utf-8');
mimeTypeParser.toString(); // 'text/html;charset=utf-8'
mimeTypeParser.getType(); // 'text'
mimeTypeParser.getSubtype(); // 'html'
mimeTypeParser.getEssence(); // 'text/html'
mimeTypeParser.getParameters(); // Map(1) { 'charset' => 'utf-8' }
mimeTypeParser.getParameter('charset'); // 'utf-8'
mimeTypeParser.getParameter('foo'); // undefined
Constructor
new MIMETypeParser(inputMimeType: string)
Parameters
inputMimeType
- MIME type value
Methods
toString(): string
- Get the entire serialized MIME type string.
getType(): string
- Get the type part of MIME type.
getSubtype(): string
- Get the subtype part of MIME type.
getEssence(): string
- Get the essence part (type/subtype) of MIME type.
getParameters(): Map<string, string>
- Get the parameters part of MIME type.
getParameter(key: string): string | undefined
- Get the value of parameters associated with the specified key of MIME type.