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

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

primeNG components

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