goldies
    Preparing search index...

    Function getFileType

    • Returns the type of a file based on its extension.

      Parameters

      • extension: string

        The file extension to check ('jpg'), or a file name or path ('photo.jpg', '/tmp/backup.tar.gz'). Only the text after the last . is used, and matching is case-insensitive.

      Returns string

      The type of the file (document, video, audio, archive, image, or unknown).

      getFileType('jpg') // returns 'image'
      getFileType('report.PDF') // returns 'document'