Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # mime-types
  2. [![NPM Version][npm-version-image]][npm-url]
  3. [![NPM Downloads][npm-downloads-image]][npm-url]
  4. [![Node.js Version][node-version-image]][node-version-url]
  5. [![Build Status][travis-image]][travis-url]
  6. [![Test Coverage][coveralls-image]][coveralls-url]
  7. The ultimate javascript content-type utility.
  8. Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except:
  9. - __No fallbacks.__ Instead of naively returning the first available type,
  10. `mime-types` simply returns `false`, so do
  11. `var type = mime.lookup('unrecognized') || 'application/octet-stream'`.
  12. - No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.
  13. - No `.define()` functionality
  14. - Bug fixes for `.lookup(path)`
  15. Otherwise, the API is compatible with `mime` 1.x.
  16. ## Install
  17. This is a [Node.js](https://nodejs.org/en/) module available through the
  18. [npm registry](https://www.npmjs.com/). Installation is done using the
  19. [`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
  20. ```sh
  21. $ npm install mime-types
  22. ```
  23. ## Adding Types
  24. All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db),
  25. so open a PR there if you'd like to add mime types.
  26. ## API
  27. ```js
  28. var mime = require('mime-types')
  29. ```
  30. All functions return `false` if input is invalid or not found.
  31. ### mime.lookup(path)
  32. Lookup the content-type associated with a file.
  33. ```js
  34. mime.lookup('json') // 'application/json'
  35. mime.lookup('.md') // 'text/markdown'
  36. mime.lookup('file.html') // 'text/html'
  37. mime.lookup('folder/file.js') // 'application/javascript'
  38. mime.lookup('folder/.htaccess') // false
  39. mime.lookup('cats') // false
  40. ```
  41. ### mime.contentType(type)
  42. Create a full content-type header given a content-type or extension.
  43. When given an extension, `mime.lookup` is used to get the matching
  44. content-type, otherwise the given content-type is used. Then if the
  45. content-type does not already have a `charset` parameter, `mime.charset`
  46. is used to get the default charset and add to the returned content-type.
  47. ```js
  48. mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
  49. mime.contentType('file.json') // 'application/json; charset=utf-8'
  50. mime.contentType('text/html') // 'text/html; charset=utf-8'
  51. mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'
  52. // from a full path
  53. mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
  54. ```
  55. ### mime.extension(type)
  56. Get the default extension for a content-type.
  57. ```js
  58. mime.extension('application/octet-stream') // 'bin'
  59. ```
  60. ### mime.charset(type)
  61. Lookup the implied default charset of a content-type.
  62. ```js
  63. mime.charset('text/markdown') // 'UTF-8'
  64. ```
  65. ### var type = mime.types[extension]
  66. A map of content-types by extension.
  67. ### [extensions...] = mime.extensions[type]
  68. A map of extensions by content-type.
  69. ## License
  70. [MIT](LICENSE)
  71. [coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master
  72. [coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master
  73. [node-version-image]: https://badgen.net/npm/node/mime-types
  74. [node-version-url]: https://nodejs.org/en/download
  75. [npm-downloads-image]: https://badgen.net/npm/dm/mime-types
  76. [npm-url]: https://npmjs.org/package/mime-types
  77. [npm-version-image]: https://badgen.net/npm/v/mime-types
  78. [travis-image]: https://badgen.net/travis/jshttp/mime-types/master
  79. [travis-url]: https://travis-ci.org/jshttp/mime-types