Skip to content
forked from broofa/mime

A super simple utility library for dealing with mime-types

Notifications You must be signed in to change notification settings

simplegeo/node-mime

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A super simple utility library for dealing with mime-types

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%