Socket
Book a DemoInstallSign in
Socket

lighter-mime

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lighter-mime

A lightweight JavaScript MIME type library.

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

lighter-mime

Chat Version Downloads Build Coverage Style

The lighter-mime module combines speed and support by immediately loading a basic set of MIME types, and lazily loading a full set.

Installation

From your project directory, install and save as a dependency:

npm install --save lighter-mime

API

The lighter-mime package exports an object whose keys are lowercase file extensions and values are MIME types.

mime

The basic mapping is pretty simple:

var mime = require('lighter-mime')
console.log(mime)

//> { css: 'text/css',
//    gif: 'image/gif',
//    html: 'text/html',
//    ico: 'image/x-icon',
//    jpg: 'image/jpg',
//    js: 'application/javascript',
//    json: 'application/json',
//    png: 'image/png',
//    svg: 'image/svg+xml',
//    txt: 'text/plain',
//    xml: 'application/xml' }

mime.set(extension, type)

Set or overwrite a MIME type mapping for a given extension.

var mime = require('lighter-mime')
console.log(mime.js)
//> 'application/javascript'

// Let's consider JavaScript to be text.
mime.set('js', 'text/javascript')
console.log(mime.js)
//> 'text/javascript'

mime.load()

Load the comprehensive list immediately (and return the mapping).

var mime = require('lighter-mime').load()
console.log(mime.docx)
//> 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'

mime.timeout(milliseconds)

Delay loading the comprehensive list for a specified number of milliseconds, rather than the default 1 millisecond.

More on lighter-mime...

Keywords

utility

FAQs

Package last updated on 02 Dec 2015

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.