diff options
author | Minteck <minteck@phoenixnet.tech> | 2021-10-17 20:08:04 +0200 |
---|---|---|
committer | Minteck <minteck@phoenixnet.tech> | 2021-10-17 20:08:04 +0200 |
commit | 3a94acf27ea1eff8bd1125450f07c0c366332e80 (patch) | |
tree | 5bd619df0b7e04afc174df98736a527477522acb /node_modules/node-mime | |
download | rainbow-3a94acf27ea1eff8bd1125450f07c0c366332e80.tar.gz rainbow-3a94acf27ea1eff8bd1125450f07c0c366332e80.tar.bz2 rainbow-3a94acf27ea1eff8bd1125450f07c0c366332e80.zip |
Initial commit
Diffstat (limited to 'node_modules/node-mime')
-rw-r--r-- | node_modules/node-mime/README.md | 4 | ||||
-rw-r--r-- | node_modules/node-mime/package.json | 48 | ||||
-rw-r--r-- | node_modules/node-mime/src/index.js | 127 |
3 files changed, 179 insertions, 0 deletions
diff --git a/node_modules/node-mime/README.md b/node_modules/node-mime/README.md new file mode 100644 index 0000000..2ce3ebe --- /dev/null +++ b/node_modules/node-mime/README.md @@ -0,0 +1,4 @@ +mime +===== + +mime type/ext functions
\ No newline at end of file diff --git a/node_modules/node-mime/package.json b/node_modules/node-mime/package.json new file mode 100644 index 0000000..b4868bc --- /dev/null +++ b/node_modules/node-mime/package.json @@ -0,0 +1,48 @@ +{ + "_from": "node-mime", + "_id": "node-mime@1.0.0", + "_inBundle": false, + "_integrity": "sha1-NZqR94HheWFawYorKC0MJuaB1FQ=", + "_location": "/node-mime", + "_phantomChildren": {}, + "_requested": { + "type": "tag", + "registry": true, + "raw": "node-mime", + "name": "node-mime", + "escapedName": "node-mime", + "rawSpec": "", + "saveSpec": null, + "fetchSpec": "latest" + }, + "_requiredBy": [ + "#USER", + "/" + ], + "_resolved": "https://registry.npmjs.org/node-mime/-/node-mime-1.0.0.tgz", + "_shasum": "359a91f781e179615ac18a2b282d0c26e681d454", + "_spec": "node-mime", + "_where": "/mnt/windisk/Users/Nathan/Documents/Projets/MPWS", + "author": { + "name": "Nathan Faucett" + }, + "bugs": { + "url": "https://github.com/nathanfaucett/node-mime/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "mime type/ext functions", + "homepage": "https://github.com/nathanfaucett/node-mime#readme", + "keywords": [ + "mime.js", + "mime" + ], + "license": "BSD", + "main": "./src/index.js", + "name": "node-mime", + "repository": { + "type": "git", + "url": "git+https://github.com/nathanfaucett/node-mime.git" + }, + "version": "1.0.0" +} diff --git a/node_modules/node-mime/src/index.js b/node_modules/node-mime/src/index.js new file mode 100644 index 0000000..c472624 --- /dev/null +++ b/node_modules/node-mime/src/index.js @@ -0,0 +1,127 @@ +var SPLITER = /[ ,]+/; + + +function Mime(){ + + this.types = {}; + this.extensions = {}; + + this.defaultType = "text/plain"; + this.defaultExtension = "txt"; + + this.register("*/*", "*"); + + this.register("text/html", "html htm xhtml"); + this.register("text/plain", "txt"); + this.register("application/javascript", "js"); + this.register("text/css", "css"); + this.register("text/calendar", "ics"); + this.register("text/csv", "csv"); + + this.register("image/png", "png"); + this.register("image/jpeg", "jpeg jpg"); + this.register("image/gif", "gif"); + this.register("image/bmp", "bmp"); + this.register("image/x-icon", "ico"); + this.register("image/tiff", "tiff tif"); + this.register("image/svg+xml", "svg"); + + this.register("video/mpeg", "mpg mpeg mpe"); + + this.register("application/xml", "xml"); + this.register("application/rss+xml", "rss"); + this.register("application/atom+xml", "atom"); + this.register("application/x-yaml", "yaml"); + + this.register("multipart/form-data", "multipart_form"); + this.register("application/x-www-form-urlencoded", "url_encoded_form"); + + this.register("application/x-font-ttf", "ttf"); + this.register("application/x-font-truetype", "ttf"); + this.register("application/x-font-opentype", "otf"); + this.register("application/font-woff", "woff"); + this.register("application/vnd.ms-fontobject", "eot"); + + this.register("application/json", "map"); + this.register("application/json", "json"); + this.register("application/pdf", "pdf"); + this.register("application/zip", "zip"); +} + + +Mime.prototype.register = function(type, exts){ + var types = this.types, + extensions = this.extensions, + ext, + i; + + exts = exts.split(SPLITER); + + for (i = exts.length; i--;) { + ext = exts[i]; + if (!ext.length) continue; + if (!extensions[ext]) extensions[ext] = type; + } + + if (!types[type] && exts[0]) types[type] = exts[0]; + + return this; +}; + + +Mime.prototype.unregister = function(exts){ + var types = this.types, + extensions = this.extensions, + key, i; + + exts = exts.split(SPLITER); + + for (i = exts.length; i--;) { + ext = exts[i]; + if (!ext.length) continue; + + for (key in types) { + + if (types[key] === ext) types[key] = undefined; + } + + extensions[ext] = undefined; + } + + return this; +}; + + +Mime.prototype.unregisterType = function(type){ + var types = this.types, + extensions = this.extensions, + key, i; + + for (key in extensions) { + + if (extensions[key] === type) extensions[key] = undefined; + } + + types[type] = undefined; + + return this; +}; + + +Mime.prototype.lookUpType = function(ext, fallback){ + var type = this.extensions[ext]; + fallback = fallback === undefined ? true : !!fallback; + + return type ? type : fallback ? this.defaultType : undefined; +}; + + +Mime.prototype.lookUpExt = function(type, fallback){ + var ext = this.types[type]; + fallback = fallback === undefined ? true : !!fallback; + + return ext ? ext : fallback ? this.defaultExtension : undefined; +}; + + +module.exports = new Mime;
\ No newline at end of file |