source: trip-planner-front/node_modules/mime/README.md@ b738035

Last change on this file since b738035 was e29cc2e, checked in by Ema <ema_spirova@…>, 3 years ago

primeNG components

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[e29cc2e]1# mime
[6a3a178]2
[e29cc2e]3Comprehensive MIME type mapping API based on mime-db module.
[6a3a178]4
5## Install
6
[e29cc2e]7Install with [npm](http://github.com/isaacs/npm):
[6a3a178]8
[e29cc2e]9 npm install mime
[6a3a178]10
[e29cc2e]11## Contributing / Testing
[6a3a178]12
[e29cc2e]13 npm run test
[6a3a178]14
[e29cc2e]15## Command Line
[6a3a178]16
[e29cc2e]17 mime [path_string]
[6a3a178]18
[e29cc2e]19E.g.
[6a3a178]20
[e29cc2e]21 > mime scripts/jquery.js
22 application/javascript
[6a3a178]23
[e29cc2e]24## API - Queries
[6a3a178]25
[e29cc2e]26### mime.lookup(path)
27Get the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.'). E.g.
[6a3a178]28
[e29cc2e]29```js
30var mime = require('mime');
[6a3a178]31
[e29cc2e]32mime.lookup('/path/to/file.txt'); // => 'text/plain'
33mime.lookup('file.txt'); // => 'text/plain'
34mime.lookup('.TXT'); // => 'text/plain'
35mime.lookup('htm'); // => 'text/html'
[6a3a178]36```
37
[e29cc2e]38### mime.default_type
39Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.)
[6a3a178]40
[e29cc2e]41### mime.extension(type)
42Get the default extension for `type`
[6a3a178]43
[e29cc2e]44```js
45mime.extension('text/html'); // => 'html'
46mime.extension('application/octet-stream'); // => 'bin'
47```
[6a3a178]48
[e29cc2e]49### mime.charsets.lookup()
[6a3a178]50
[e29cc2e]51Map mime-type to charset
[6a3a178]52
[e29cc2e]53```js
54mime.charsets.lookup('text/plain'); // => 'UTF-8'
[6a3a178]55```
56
[e29cc2e]57(The logic for charset lookups is pretty rudimentary. Feel free to suggest improvements.)
[6a3a178]58
[e29cc2e]59## API - Defining Custom Types
[6a3a178]60
[e29cc2e]61Custom type mappings can be added on a per-project basis via the following APIs.
[6a3a178]62
[e29cc2e]63### mime.define()
[6a3a178]64
[e29cc2e]65Add custom mime/extension mappings
[6a3a178]66
[e29cc2e]67```js
68mime.define({
69 'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],
70 'application/x-my-type': ['x-mt', 'x-mtt'],
71 // etc ...
72});
[6a3a178]73
[e29cc2e]74mime.lookup('x-sft'); // => 'text/x-some-format'
[6a3a178]75```
76
[e29cc2e]77The first entry in the extensions array is returned by `mime.extension()`. E.g.
[6a3a178]78
[e29cc2e]79```js
80mime.extension('text/x-some-format'); // => 'x-sf'
[6a3a178]81```
82
[e29cc2e]83### mime.load(filepath)
[6a3a178]84
[e29cc2e]85Load mappings from an Apache ".types" format file
[6a3a178]86
[e29cc2e]87```js
88mime.load('./my_project.types');
[6a3a178]89```
[e29cc2e]90The .types file format is simple - See the `types` dir for examples.
Note: See TracBrowser for help on using the repository browser.