GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — node-app/node_modules/mime-types at main · storemap/node-app

Expand file tree

/

mime-types

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

mime-types

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
lib
lib
 
 
test
test
 
 
.npmignore
.npmignore
 
 
.travis.yml
.travis.yml
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
SOURCES.md
SOURCES.md
 
 
build.js
build.js
 
 
component.json
component.json
 
 
package.json
package.json
 
 

README.md

Outline

mime-types Build Status NPM version

The ultimate javascript content-type utility.

Install

$ npm install mime-types

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 adding the type to custom.json and a reference link to the sources.

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

API

var mime = require('mime-types')

All functions return false if input is invalid or not found.

mime.lookup(path)

Lookup the content-type associated with a file.

mime.lookup('json')           // 'application/json'
mime.lookup('.md')            // 'text/x-markdown'
mime.lookup('file.html')      // 'text/html'
mime.lookup('folder/file.js') // 'application/javascript'

mime.lookup('cats') // false

mime.contentType(type)

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

mime.contentType('markdown')  // 'text/x-markdown; charset=utf-8'
mime.contentType('file.json') // 'application/json; charset=utf-8'

mime.extension(type)

Get the default extension for a content-type.

mime.extension('application/octet-stream') // 'bin'

mime.charset(type)

Lookup the implied default charset of a content-type.

mime.charset('text/x-markdown') // 'UTF-8'

mime.types[extension] = type

A map of content-types by extension.

mime.extensions[type] = [extensions]

A map of extensions by content-type.

mime.define(types)

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

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

See the .json files in lib/ for examples.

License

MIT

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.