A builder class for the metadata object.

const metadata = MetadataBuilder.create("Title", "Author", "Description")
.set("publisher", "Publisher")
.add("subject", "Subject 1")
.add("subject", "Subject 2")
.build();

Accessors

Methods

  • Add a metadata key-value pair.

    In contrast to MetadataBuilder.set, this method adds a value to the metadata key. For properties that can have only a single value, use MetadataBuilder.set instead.

    Type Parameters

    • Key extends
          | "type"
          | "source"
          | "language"
          | "identifier"
          | "publisher"
          | "contributor"
          | "relation"
          | "rights"
          | "subject"

      The key of the metadata.

    Parameters

    • key: Key

      The key of the metadata.

    • value: Metadata[Key]

      The value of the metadata.

    Returns this

  • Build the metadata object.

    Returns {
        additional?: Record<string, string>;
        author: string;
        contributor?: string | string[];
        coverage?: string;
        date: string;
        description: string;
        format?: string;
        identifier: string | string[];
        language: string | string[];
        publisher: string | string[];
        relation?: string | string[];
        rights: string | string[];
        source?: string | string[];
        subject?: string | string[];
        title: string;
        type: string | string[];
    }

    The parsed metadata object.

    • Optionaladditional?: Record<string, string>
    • author: string
    • Optionalcontributor?: string | string[]
    • Optionalcoverage?: string
    • date: string
    • description: string
    • Optionalformat?: string
    • identifier: string | string[]
    • language: string | string[]
    • publisher: string | string[]
    • Optionalrelation?: string | string[]
    • rights: string | string[]
    • Optionalsource?: string | string[]
    • Optionalsubject?: string | string[]
    • title: string
    • type: string | string[]

    Thrown if the metadata object is invalid.

  • Set a metadata key-value pair.

    In contrast to MetadataBuilder.add, this method sets a single value for the metadata key. For properties that can have multiple values, use MetadataBuilder.add to add a value instead.

    Type Parameters

    • Key extends
          | "type"
          | "source"
          | "title"
          | "description"
          | "language"
          | "author"
          | "identifier"
          | "publisher"
          | "contributor"
          | "date"
          | "format"
          | "relation"
          | "coverage"
          | "rights"
          | "subject"

      The key of the metadata.

    Parameters

    • key: Key

      The key of the metadata.

    • value: Metadata[Key]

      The value of the metadata.

    Returns this

  • Set an additional metadata key-value pair.

    Parameters

    • key: string

      The key of the metadata.

    • value: string

      The value of the metadata.

    Returns this