CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
README.md91 linesDownload Raw Back to mime
1# mime2 3Comprehensive MIME type mapping API based on mime-db module.4 5## Install6 7Install with [npm](http://github.com/isaacs/npm):8 9    npm install mime10 11## Contributing / Testing12 13    npm run test14 15## Command Line16 17    mime [path_string]18 19E.g.20 21    > mime scripts/jquery.js22    application/javascript23 24## API - Queries25 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```js30var 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_type39Sets 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```js45mime.extension('text/html');                 // => 'html'46mime.extension('application/octet-stream');  // => 'bin'47```48 49### mime.charsets.lookup()50 51Map mime-type to charset52 53```js54mime.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 Types60 61Custom type mappings can be added on a per-project basis via the following APIs.62 63### mime.define()64 65Add custom mime/extension mappings66 67```js68mime.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```js80mime.extension('text/x-some-format'); // => 'x-sf'81```82 83### mime.load(filepath)84 85Load mappings from an Apache ".types" format file86 87```js88mime.load('./my_project.types');89```90The .types file format is simple -  See the `types` dir for examples.91 
basant307/AI_Governance_Project · CoolFace