Socket
Socket
Sign inDemoInstall

mime

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mime

A comprehensive library for mime-type mapping


Version published
Weekly downloads
63M
increased by4.43%
Maintainers
1
Weekly downloads
 
Created

What is mime?

The mime npm package is a utility for handling and transforming file MIME types. It provides functionality to lookup the MIME type for a file based on its extension, determine the default extension for a MIME type, and define custom MIME type mappings.

What are mime's main functionalities?

Lookup MIME type by extension

This feature allows you to get the MIME type for a given file extension. In the code sample, we are looking up the MIME type for a '.json' file, which returns 'application/json'.

const mime = require('mime');
const mimeType = mime.getType('json'); // 'application/json'

Lookup extension by MIME type

This feature enables you to find the default file extension for a given MIME type. In the code sample, we are finding the extension for the MIME type 'application/json', which returns 'json'.

const mime = require('mime');
const extension = mime.getExtension('application/json'); // 'json'

Define custom MIME type mappings

This feature allows you to define custom MIME type mappings. In the code sample, we are adding a custom MIME type 'text/x-some-format' with multiple extensions. The second argument 'true' indicates that the custom types should take precedence over the built-in types.

const mime = require('mime');
mime.define({ 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'] }, true);

Other packages similar to mime

Keywords

FAQs

Package last updated on 17 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc