2.0.6 • Published 3 years ago

mime-file-extension v2.0.6

Weekly downloads
55
License
ISC
Repository
github
Last release
3 years ago

mime-file-extension

This library solving problem of file extension for concrete mime types and vice versa.

Install

npm install mime-file-extension

Methods

  • getFileExtensions(mimeType, full)
    	> mimeType - String representing mime type eg: "audio/ogg"
    	> full - Boolean  - if true return value contains dot at the beginning[".jpeg",  ".jpg",  ".jpe"]
  • getMimeType(extension)
    	> extension - String representing file extension with or without dot at the beginning

Usage

const mfe = require("mime-file-extension");

console.log(mfe.getFileExtensions("text/csv")) // ["csv"]
console.log(mfe.getFileExtensions("audio/ogg")) // ["oga","ogg","spx"]
console.log(mfe.getFileExtensions("image/jpeg", true)) // [".jpeg", ".jpe", ".jpg"]

console.log(mfe.getMimeType("gif")) // "image/gif"
console.log(mfe.getMimeType("m2a")) // "audio/mpeg"
console.log(mfe.getMimeType("m3a")) // "audio/mpeg"
console.log(mfe.getMimeType(".mp3")) // "audio/mpeg"

Missing format ?

Post your request under Missing format

Changelog

  • 2.0 move to typescript implementation adding typescript linting redefine building types map json - prebuild scripts adding new mimetypes
2.0.3

3 years ago

2.0.2

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.6

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago