Skip to content

Latest commit

 

History

History
22 lines (14 loc) · 785 Bytes

README.md

File metadata and controls

22 lines (14 loc) · 785 Bytes

Extension to MIME type & MIME type to extension

This module provides a map of MIME types to file extensions.

Usage

// ES6

import mimeExtMap from "ext-mime-map"

mimeExtMap(".js")  // text/javascript
mimeExtMap("application/octet-stream")  // [ ".a", ".bin", ".bpk", ".deploy", ".dist", ".distz", ".dmg", ".dms",  ".dump", ".elc", ".iso", ".lha", ".lrf", ".lzh", ".o", ".obj", ".pkg", ".so" ]
mimeExtMap("application/json")  // .json
mimeExtMap("application/zip")  // .zip
mimeExtMap("application/x-zip-compressed")  // "" (not found)

Note: When searching for MIME type by file extension, the extension must start with a dot. For example, .js and not js.

For more complicated use cases you can use map.json - a JSON map of MIME types to file extensions.