Changeset e29cc2e for trip-planner-front/node_modules/mime/README.md
- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/mime/README.md
r59329aa re29cc2e 1 <!-- 2 -- This file is auto-generated from src/README_js.md. Changes should be made there. 3 --> 4 # Mime 1 # mime 5 2 6 A comprehensive, compact MIME type module. 7 8 [![Build Status](https://travis-ci.org/broofa/mime.svg?branch=master)](https://travis-ci.org/broofa/mime) 9 10 ## Version 2 Notes 11 12 Version 2 is a breaking change from 1.x as the semver implies. Specifically: 13 14 * `lookup()` renamed to `getType()` 15 * `extension()` renamed to `getExtension()` 16 * `charset()` and `load()` methods have been removed 17 18 If you prefer the legacy version of this module please `npm install mime@^1`. Version 1 docs may be found [here](https://github.com/broofa/mime/tree/v1.4.0). 3 Comprehensive MIME type mapping API based on mime-db module. 19 4 20 5 ## Install 21 6 22 ### NPM 23 ``` 24 npm install mime 25 ``` 7 Install with [npm](http://github.com/isaacs/npm): 26 8 27 ### Browser 9 npm install mime 28 10 29 It is recommended that you use a bundler such as 30 [webpack](https://webpack.github.io/) or [browserify](http://browserify.org/) to 31 package your code. However, browser-ready versions are available via wzrd.in. 32 E.g. For the full version: 11 ## Contributing / Testing 33 12 34 <script src="https://wzrd.in/standalone/mime@latest"></script> 35 <script> 36 mime.getType(...); // etc. 37 </script> 38 39 Or, for the `mime/lite` version: 40 41 <script src="https://wzrd.in/standalone/mime%2flite@latest"></script> 42 <script> 43 mimelite.getType(...); // (Note `mimelite` here) 44 </script> 45 46 ## Quick Start 47 48 For the full version (800+ MIME types, 1,000+ extensions): 49 50 ```javascript 51 const mime = require('mime'); 52 53 mime.getType('txt'); // ⇨ 'text/plain' 54 mime.getExtension('text/plain'); // ⇨ 'txt' 55 ``` 56 57 See [Mime API](#mime-api) below for API details. 58 59 ## Lite Version 60 61 There is also a "lite" version of this module that omits vendor-specific 62 (`*/vnd.*`) and experimental (`*/x-*`) types. It weighs in at ~2.5KB, compared 63 to 8KB for the full version. To load the lite version: 64 65 ```javascript 66 const mime = require('mime/lite'); 67 ``` 68 69 ## Mime .vs. mime-types .vs. mime-db modules 70 71 For those of you wondering about the difference between these [popular] NPM modules, 72 here's a brief rundown ... 73 74 [`mime-db`](https://github.com/jshttp/mime-db) is "the source of 75 truth" for MIME type information. It is not an API. Rather, it is a canonical 76 dataset of mime type definitions pulled from IANA, Apache, NGINX, and custom mappings 77 submitted by the Node.js community. 78 79 [`mime-types`](https://github.com/jshttp/mime-types) is a thin 80 wrapper around mime-db that provides an API drop-in compatible(ish) with `mime @ < v1.3.6` API. 81 82 `mime` is, as of v2, a self-contained module bundled with a pre-optimized version 83 of the `mime-db` dataset. It provides a simplified API with the following characteristics: 84 85 * Intelligently resolved type conflicts (See [mime-score](https://github.com/broofa/mime-score) for details) 86 * Method naming consistent with industry best-practices 87 * Compact footprint. E.g. The minified+compressed sizes of the various modules: 88 89 Module | Size 90 --- | --- 91 `mime-db` | 18 KB 92 `mime-types` | same as mime-db 93 `mime` | 8 KB 94 `mime/lite` | 2 KB 95 96 ## Mime API 97 98 Both `require('mime')` and `require('mime/lite')` return instances of the MIME 99 class, documented below. 100 101 Note: Inputs to this API are case-insensitive. Outputs (returned values) will 102 be lowercase. 103 104 ### new Mime(typeMap, ... more maps) 105 106 Most users of this module will not need to create Mime instances directly. 107 However if you would like to create custom mappings, you may do so as follows 108 ... 109 110 ```javascript 111 // Require Mime class 112 const Mime = require('mime/Mime'); 113 114 // Define mime type -> extensions map 115 const typeMap = { 116 'text/abc': ['abc', 'alpha', 'bet'], 117 'text/def': ['leppard'] 118 }; 119 120 // Create and use Mime instance 121 const myMime = new Mime(typeMap); 122 myMime.getType('abc'); // ⇨ 'text/abc' 123 myMime.getExtension('text/def'); // ⇨ 'leppard' 124 ``` 125 126 If more than one map argument is provided, each map is `define()`ed (see below), in order. 127 128 ### mime.getType(pathOrExtension) 129 130 Get mime type for the given path or extension. E.g. 131 132 ```javascript 133 mime.getType('js'); // ⇨ 'application/javascript' 134 mime.getType('json'); // ⇨ 'application/json' 135 136 mime.getType('txt'); // ⇨ 'text/plain' 137 mime.getType('dir/text.txt'); // ⇨ 'text/plain' 138 mime.getType('dir\\text.txt'); // ⇨ 'text/plain' 139 mime.getType('.text.txt'); // ⇨ 'text/plain' 140 mime.getType('.txt'); // ⇨ 'text/plain' 141 ``` 142 143 `null` is returned in cases where an extension is not detected or recognized 144 145 ```javascript 146 mime.getType('foo/txt'); // ⇨ null 147 mime.getType('bogus_type'); // ⇨ null 148 ``` 149 150 ### mime.getExtension(type) 151 Get extension for the given mime type. Charset options (often included in 152 Content-Type headers) are ignored. 153 154 ```javascript 155 mime.getExtension('text/plain'); // ⇨ 'txt' 156 mime.getExtension('application/json'); // ⇨ 'json' 157 mime.getExtension('text/html; charset=utf8'); // ⇨ 'html' 158 ``` 159 160 ### mime.define(typeMap[, force = false]) 161 162 Define [more] type mappings. 163 164 `typeMap` is a map of type -> extensions, as documented in `new Mime`, above. 165 166 By default this method will throw an error if you try to map a type to an 167 extension that is already assigned to another type. Passing `true` for the 168 `force` argument will suppress this behavior (overriding any previous mapping). 169 170 ```javascript 171 mime.define({'text/x-abc': ['abc', 'abcd']}); 172 173 mime.getType('abcd'); // ⇨ 'text/x-abc' 174 mime.getExtension('text/x-abc') // ⇨ 'abc' 175 ``` 13 npm run test 176 14 177 15 ## Command Line 178 16 179 mime [path_ or_extension]17 mime [path_string] 180 18 181 19 E.g. … … 184 22 application/javascript 185 23 186 ---- 187 Markdown generated from [src/README_js.md](src/README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd) 24 ## API - Queries 25 26 ### mime.lookup(path) 27 Get 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 30 var mime = require('mime'); 31 32 mime.lookup('/path/to/file.txt'); // => 'text/plain' 33 mime.lookup('file.txt'); // => 'text/plain' 34 mime.lookup('.TXT'); // => 'text/plain' 35 mime.lookup('htm'); // => 'text/html' 36 ``` 37 38 ### mime.default_type 39 Sets the mime type returned when `mime.lookup` fails to find the extension searched for. (Default is `application/octet-stream`.) 40 41 ### mime.extension(type) 42 Get the default extension for `type` 43 44 ```js 45 mime.extension('text/html'); // => 'html' 46 mime.extension('application/octet-stream'); // => 'bin' 47 ``` 48 49 ### mime.charsets.lookup() 50 51 Map mime-type to charset 52 53 ```js 54 mime.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 61 Custom type mappings can be added on a per-project basis via the following APIs. 62 63 ### mime.define() 64 65 Add custom mime/extension mappings 66 67 ```js 68 mime.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 74 mime.lookup('x-sft'); // => 'text/x-some-format' 75 ``` 76 77 The first entry in the extensions array is returned by `mime.extension()`. E.g. 78 79 ```js 80 mime.extension('text/x-some-format'); // => 'x-sf' 81 ``` 82 83 ### mime.load(filepath) 84 85 Load mappings from an Apache ".types" format file 86 87 ```js 88 mime.load('./my_project.types'); 89 ``` 90 The .types file format is simple - See the `types` dir for examples.
Note:
See TracChangeset
for help on using the changeset viewer.