Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Dec 17, 2023 via pnpm

mime-types 1.0.0

ultimate mime type utility
Package summary
Share
0
issues
0
licenses
Package created
2 May 2014
Version published
12 May 2014
Maintainers
2
Total deps
0
Direct deps
0
License
MIT

Issues

0
This package has no issues

Frequently Asked Questions

What does mime-types do?

Mime-types is a content-type utility in JavaScript. It precisely offers its services due to its feature of not falling back naively to the first available type. Instead, when a file type is unrecognized, it returns 'false'. It is a node.js module available via npm registry and all its types are rooted in mime-db. It provides various API functionalities such as looking up the content-type associated with a file, creating a full content-type header given an extension or content-type, fetching the default extension for a content-type, checking the implied default charset of a content-type, and more.

How do you use mime-types?

Usage of mime-types is fairly straightforward after you've installed it using the npm install command npm install mime-types. Post-installation, you can require it in your JavaScript file with the following command var mime = require('mime-types'). The various functions provide different use cases:

  • Looking up a content-type:
mime.lookup('json'); //returns 'application/json'
  • Creating a full content-type header from an extension or content-type:
mime.contentType('markdown'); //returns 'text/x-markdown; charset=utf-8'
  • Getting the default extension for a content-type:
mime.extension('application/octet-stream'); //returns 'bin'
  • Looking up the implied default charset of a content-type:
mime.charset('text/markdown'); //returns 'UTF-8'
  • A map of content-types by extension can be found at mime.types[extension] and a map of extensions by content-type at mime.extensions[type].

Where are the mime-types docs?

Mime-types documentation can be found on the project's GitHub page at https://github.com/jshttp/mime-types. The readme file on the project's GitHub page offers detailed understanding of mime-types, covering different aspects like installation, usage and API. It should be your go-to guide for any queries regarding the usage of this package.