A super simple utility library for dealing with mime-types
JavaScript
Clone or download
Pull request Compare This branch is 17 commits ahead, 222 commits behind broofa:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
debian
README.md
index.js
mime.js
mime.types
node.types
package.json
test.js

README.md

A library for doing simple mime-type lookups.

var mime = require('mime');

mime.lookup('/path/to/file.txt');         // => 'text/plain'
mime.lookup('file.txt');                  // => 'text/plain'
mime.lookup('.txt');                      // => 'text/plain'
mime.lookup('htm');                       // => 'text/html'

... and extension lookups by mime-type

mime.extension('text/html');                 // => 'html'
mime.extension('application/octet-stream');  // => 'buffer'

'Need to define your own types? Just load up an Apache-format 'types' file (see mime.types or node.types for an example). Your types are "overlaid" onto the default mime.types and node.types.

mime.loadFile('./project.types');

It also includes rudimentary logic for determining charsets. (Useful in a web framework):

mime.charset.lookup('text/plain');        // => 'UTF-8'

Install with npm:

npm install mime