mimekit-ts - v1.0.0
    Preparing search index...

    Class ContentType

    Represents a Content-Type header value.

    Index
    • Creates a new content type with the specified media type and subtype.

      Parameters

      • mediaType: string

        The media type.

      • mediaSubtype: string

        The media subtype.

      Returns ContentType

      mediaType or mediaSubtype is null or undefined.

    parameters: ParameterList

    The content type parameters.

    onChanged: (() => void) | null = null

    Invoked when the content type changes.

    • get boundary(): string | null

      The boundary parameter, if available.

      Returns string | null

    • set boundary(value: string | null): void

      Parameters

      • value: string | null

      Returns void

    • get charset(): string | null

      The charset parameter, if available.

      Returns string | null

    • set charset(value: string | null): void

      Parameters

      • value: string | null

      Returns void

    • get format(): string | null

      The format parameter, if available.

      Returns string | null

    • set format(value: string | null): void

      Parameters

      • value: string | null

      Returns void

    • get name(): string | null

      The name parameter, if available.

      Returns string | null

    • set name(value: string | null): void

      Parameters

      • value: string | null

      Returns void

    • Determines whether this content type matches the specified media type and subtype.

      The * wildcard may be used for either argument.

      Parameters

      • mediaType: string

        The media type.

      • mediaSubtype: string

        The media subtype.

      Returns boolean

      true if this content type matches; otherwise, false.

      mediaType or mediaSubtype is null or undefined.

    • Serializes this content type.

      Parameters

      • options: FormatOptions = FormatOptions.default

        The formatting options.

      • charset: CharsetEncoding = utf8

        The charset to use when encoding parameter values.

      • encode: boolean = false

        If true, parameter values will be encoded.

      Returns string

      The serialized string.

    • Parses a content type from text or bytes.

      Parameters

      • input: string | Uint8Array<ArrayBufferLike>

        The input to parse.

      • options: ParserOptions = ParserOptions.default

        The parser options.

      Returns Result<ContentType>

      A Result; { ok: false } with a MimeError on malformed input.

      input is null or undefined.

    • Attempts to parse a content type from a byte range.

      Parameters

      • options: ParserOptions

        The parser options.

      • text: Uint8Array

        The input buffer.

      • cursor: ParseCursor

        The current parse cursor.

      • endIndex: number

        The end index of the input range.

      • Optionalpartial: { contentType: ContentType | null }

        Receives a partially parsed content type when type/subtype parsing succeeds.

      Returns Result<ContentType>

      A Result; { ok: false } with a MimeError on malformed input.