"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/mime-types/README.md" (17 Oct 2016, 2924 Bytes) of archive /windows/misc/atom-windows.zip:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.


NPM Version NPM Downloads Node.js Version Build Status Test Coverage

The ultimate javascript content-type utility.

Similar to node-mime, except:

Otherwise, the API is compatible.


sh $ npm install mime-types

Adding Types

All mime types are based on mime-db, so open a PR there if you’d like to add mime types.


js var mime = require('mime-types')

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


Lookup the content-type associated with a file.

```js 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(‘folder/.htaccess’) // false

mime.lookup(‘cats’) // false ```


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

```js mime.contentType(‘markdown’) // ‘text/x-markdown; charset=utf-8’ mime.contentType(‘file.json’) // ‘application/json; charset=utf-8’

// from a full path mime.contentType(path.extname(‘/path/to/file.json’)) // ‘application/json; charset=utf-8’ ```


Get the default extension for a content-type.

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


Lookup the implied default charset of a content-type.

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

var type = mime.types[extension]

A map of content-types by extension.

[extensions…] = mime.extensions[type]

A map of extensions by content-type.