Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hapi/mimos

Package Overview
Dependencies
Maintainers
7
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapi/mimos

Mime database interface

  • 7.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
620K
decreased by-15.11%
Maintainers
7
Weekly downloads
 
Created

What is @hapi/mimos?

@hapi/mimos is a utility library for handling and managing MIME types. It provides a way to look up MIME types based on file extensions, and vice versa, and allows for custom MIME type definitions.

What are @hapi/mimos's main functionalities?

Lookup MIME type by file extension

This feature allows you to look up the MIME type based on a file extension. In this example, the MIME type for a .txt file is retrieved.

const Mimos = require('@hapi/mimos');
const mimos = new Mimos();
const mimeType = mimos.path('file.txt');
console.log(mimeType); // { source: 'iana', compressible: true, charset: 'UTF-8', type: 'text/plain' }

Lookup file extension by MIME type

This feature allows you to look up the file extension based on a MIME type. In this example, the file extensions for the MIME type 'text/html' are retrieved.

const Mimos = require('@hapi/mimos');
const mimos = new Mimos();
const extension = mimos.type('text/html');
console.log(extension); // { source: 'iana', compressible: true, charset: 'UTF-8', type: 'text/html', extensions: [ 'html', 'htm' ] }

Custom MIME type definitions

This feature allows you to define custom MIME types. In this example, a custom MIME type 'application/x-custom' is defined and then retrieved based on the file extension.

const Mimos = require('@hapi/mimos');
const mimos = new Mimos({
  override: {
    'application/x-custom': {
      source: 'custom',
      compressible: true,
      extensions: ['custom']
    }
  }
});
const customType = mimos.path('file.custom');
console.log(customType); // { source: 'custom', compressible: true, type: 'application/x-custom', extensions: [ 'custom' ] }

Other packages similar to @hapi/mimos

Keywords

FAQs

Package last updated on 11 Feb 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