Interface ListFormat

interface ListFormat {
    format(list: Iterable<string>): string;
    formatToParts(
        list: Iterable<string>,
    ): { type: "literal" | "element"; value: string }[];
    resolvedOptions(): ResolvedListFormatOptions;
}

Methods

  • Returns a string with a language-specific representation of the list.

    Parameters

    Returns string

    A language-specific formatted string representing the elements of the list.

    MDN.

    TypeError if list includes something other than the possible values.

  • Returns an Array of objects representing the different components that can be used to format a list of values in a locale-aware fashion.

    Parameters

    • list: Iterable<string>

      An iterable object, such as an Array, to be formatted according to a locale.

    Returns { type: "literal" | "element"; value: string }[]

    An Array of components which contains the formatted parts from the list.

    MDN.

    TypeError if list includes something other than the possible values.