JSPM

  • Created
  • Published
  • Downloads 94765703
  • Score
    100M100P100Q243598F
  • License MIT

ultimate mime type utility

Package Exports

  • mime-types

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mime-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MIME Types

The ultimate mime type utility. Similar to mime except:

  • No new Mime() business, so you could do var lookup = require('mime-types').lookup
  • No fallbacks, so do var type = mime.lookup('unrecognized') || 'application/octet-stream'
  • Additional mime types are added such as jade and stylus. Feel free to add more!
  • Browser support via Browserify and Component by converting lists to JSON files

Otherwise, the API is compatible.

Adding Types

If you'd like to add additional types, simply create a PR with a link to where it's defined.

Do NOT edit mime.json or node.json. Those are pulled using build.js. You should only touch custom.json.

API

mime.lookup(path)

Lookup the mime type associated with a file. If no type is found, returns false.

mime.extension(type)

Get the default extension for the type

mime.charsets.lookup(type)

Lookup the given charset of a mime type.

mime.contentType(type)

Create a full content-type header given a mime-type or extension.

mime.types[extension] = type

Lookup a type via extension.

mime.extensions[type] = [extensions]

Lookup all the associated extensions of a mime type.

mime.define(types)

Globally add definitions. types must be an object of the form:

{
  "<mime-type>": [extensions...],
  "<mime-type>": [extensions...]
}

See the .json files in lib/ for examples.