Function getDefaultCompressor

  • The function returns a compressor based on the input format, with a default value if none is provided.

    Parameters

    • compressor: undefined | string

      The compressor parameter is a variable of type Compressor, which is likely an enum or a string type that specifies the type of image compressor to use.

    • format: string

      The format parameter is a string that represents the file format of an image. It can be '.jpg', '.jpeg', or '.svg'.

    Returns string

    a compressor name based on the input format. If the format is '.jpg' or '.jpeg', it returns the input compressor if it is not null or undefined, otherwise it returns 'mozjpeg'. If the format is '.svg', it returns undefined. For all other formats, it returns the input compressor if it is not null or undefined, otherwise it returns 'webp'.