Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/mime-types/README.md')
-rw-r--r--node_modules/mime-types/README.md45
1 files changed, 30 insertions, 15 deletions
diff --git a/node_modules/mime-types/README.md b/node_modules/mime-types/README.md
index b58cae6d2..3863339aa 100644
--- a/node_modules/mime-types/README.md
+++ b/node_modules/mime-types/README.md
@@ -1,7 +1,7 @@
# mime-types
-[![NPM Version][npm-image]][npm-url]
-[![NPM Downloads][downloads-image]][downloads-url]
+[![NPM Version][npm-version-image]][npm-url]
+[![NPM Downloads][npm-downloads-image]][npm-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
@@ -36,6 +36,8 @@ so open a PR there if you'd like to add mime types.
## API
+<!-- eslint-disable no-unused-vars -->
+
```js
var mime = require('mime-types')
```
@@ -46,11 +48,13 @@ All functions return `false` if input is invalid or not found.
Lookup the content-type associated with a file.
+<!-- eslint-disable no-undef -->
+
```js
-mime.lookup('json') // 'application/json'
-mime.lookup('.md') // 'text/markdown'
-mime.lookup('file.html') // 'text/html'
-mime.lookup('folder/file.js') // 'application/javascript'
+mime.lookup('json') // 'application/json'
+mime.lookup('.md') // 'text/markdown'
+mime.lookup('file.html') // 'text/html'
+mime.lookup('folder/file.js') // 'application/javascript'
mime.lookup('folder/.htaccess') // false
mime.lookup('cats') // false
@@ -59,10 +63,18 @@ mime.lookup('cats') // false
### mime.contentType(type)
Create a full content-type header given a content-type or extension.
+When given an extension, `mime.lookup` is used to get the matching
+content-type, otherwise the given content-type is used. Then if the
+content-type does not already have a `charset` parameter, `mime.charset`
+is used to get the default charset and add to the returned content-type.
+
+<!-- eslint-disable no-undef -->
```js
-mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
+mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
mime.contentType('file.json') // 'application/json; charset=utf-8'
+mime.contentType('text/html') // 'text/html; charset=utf-8'
+mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'
// from a full path
mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
@@ -72,6 +84,8 @@ mime.contentType(path.extname('/path/to/file.json')) // 'application/json; chars
Get the default extension for a content-type.
+<!-- eslint-disable no-undef -->
+
```js
mime.extension('application/octet-stream') // 'bin'
```
@@ -80,6 +94,8 @@ mime.extension('application/octet-stream') // 'bin'
Lookup the implied default charset of a content-type.
+<!-- eslint-disable no-undef -->
+
```js
mime.charset('text/markdown') // 'UTF-8'
```
@@ -96,13 +112,12 @@ A map of extensions by content-type.
[MIT](LICENSE)
-[npm-image]: https://img.shields.io/npm/v/mime-types.svg
+[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master
+[coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master
+[node-version-image]: https://badgen.net/npm/node/mime-types
+[node-version-url]: https://nodejs.org/en/download
+[npm-downloads-image]: https://badgen.net/npm/dm/mime-types
[npm-url]: https://npmjs.org/package/mime-types
-[node-version-image]: https://img.shields.io/node/v/mime-types.svg
-[node-version-url]: https://nodejs.org/en/download/
-[travis-image]: https://img.shields.io/travis/jshttp/mime-types/master.svg
+[npm-version-image]: https://badgen.net/npm/v/mime-types
+[travis-image]: https://badgen.net/travis/jshttp/mime-types/master
[travis-url]: https://travis-ci.org/jshttp/mime-types
-[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types/master.svg
-[coveralls-url]: https://coveralls.io/r/jshttp/mime-types
-[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg
-[downloads-url]: https://npmjs.org/package/mime-types