1.0.0 • Published 8 years ago
lighter-mime v1.0.0
lighter-mime
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...
1.0.0
8 years ago