Function match

  • Match the codec based on file name, extension name, media type or by content sniffing.

    Iterates through the list of codecs and returns the first that matches based on any of the above criteria.

    If the supplied format contains a forward slash then it is assumed to be a media type, otherwise an extension name.

    If trying to find a codec for an output, then content is more likely to be a path than actual content. This is passed through to vfile.isPath for detection.

    Parameters

    • Optional content: string

      The content as a file path (e.g. ../folder/file.txt) or raw content

    • Optional format: string

      The format as a media type (e.g. text/plain) or extension name (e.g. txt)

    • isOutput: boolean = false

      true if attempting to find a match for an output file

    Returns Promise<Codec>

    A promise that resolves to the Codec to use

Generated using TypeDoc