Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A mime type catalog for mapping file extensions to their mime type string.
JavaScript
tag: 0.0.1

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.md
mimetype.js
mimetype_test.js
package.json

README.md

mimetype-js

revision 0.0.0

Overview

I find keep making these file extension lookup tables for mime types. It's about time I put it in a module to save me the trouble.

Example

var mimetype = require('mimetype');

console.log(mimetype.lookup("myfile.txt")); // Should display text/plain
mimetype.set('.exotic', 'x-application/experimental'); // Add/update a mime type in the catalog
console.log(mimetype.lookup("myfile.exotic")); // Should display x-application/experimental
mimetype.del('.exotic'); // Removes the mime type from the catalog
console.log(mimetype.lookup("myfile.exitoc")); // Should display false
mimetype.forEach(function (ext, mime_type_string) {
  console.log(ext, mime_type_string); // Display the extension and matching mimetype in catalog
});
Something went wrong with that request. Please try again.