content-type

  • Version 3.0.0
  • Published
  • 23 kB
  • No dependencies
  • MIT license

Install

npm i content-type
yarn add content-type
pnpm add content-type

Overview

Create and parse HTTP Content-Type header

Index

Functions

function format

format: (obj: Partial<ContentType>) => string;
  • Format an object into a Content-Type header.

function parse

parse: (header: string, options?: ParseOptions) => ContentType;
  • Parse a Content-Type header.

Interfaces

interface ContentType

interface ContentType {}
  • The content type object contains a type string and optional parameters.

property index

index: number;

    property parameters

    parameters: Record<string, string>;

      property type

      type: string;

        interface ParseOptions

        interface ParseOptions {}
        • Options for parsing a Content-Type header.

        property comma

        comma?: boolean;
        • Exits early on a comma, returning the first value and parameters. This is useful for parsing Accept headers.

          false

        property parameters

        parameters?: boolean;
        • Exit early on the first semicolon, returning only the type. This is useful for parsing the MIME from Content-Type headers.

          false

        property start

        start?: number;
        • The index to start parsing from.

          0

        Package Files (1)

        Dependencies (0)

        No dependencies.

        Dev Dependencies (4)

        Peer Dependencies (0)

        No peer dependencies.

        Badge

        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/content-type.

        • Markdown
          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/content-type)
        • HTML
          <a href="https://www.jsdocs.io/package/content-type"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>