demo___customer_pitch-c4152739-a50b-4b5b-9d4d-0561461666d9.zip-extract/_dependencies/npm/mime-1.6.0/mime.js

Path
demo___customer_pitch-c4152739-a50b-4b5b-9d4d-0561461666d9.zip-extract/_dependencies/npm/mime-1.6.0/mime.js
Status
scanned
Type
file
Name
mime.js
Extension
.js
Programming language
JavaScript
Mime type
text/plain
File type
ASCII text
Tag

      
    
Rootfs path

      
    
Size
2726 (2.7 KB)
MD5
2930e6caad95dfad928d76fc1eb2e003
SHA1
f3ccff5ba27af0b9d39cc5c2f228f5ae3e276d13
SHA256
a121a0b9e780e9ae349a26227a0d25c33ebac2d52a85aae5affa84ba0f53f16c
SHA512

      
    
SHA1_git
d7efbde70b8e95fb7f67da9c8cfed11ce8ce4133
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
mime.js | 2.7 KB |

var path = require('path'); var fs = require('fs'); function Mime() { // Map of extension -> mime type this.types = Object.create(null); // Map of mime type -> extension this.extensions = Object.create(null); } /** * Define mimetype -> extension mappings. Each key is a mime-type that maps * to an array of extensions associated with the type. The first extension is * used as the default extension for the type. * * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']}); * * @param map (Object) type definitions */ Mime.prototype.define = function (map) { for (var type in map) { var exts = map[type]; for (var i = 0; i < exts.length; i++) { if (process.env.DEBUG_MIME && this.types[exts[i]]) { console.warn((this._loading || "define()").replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' + this.types[exts[i]] + ' to ' + type); } this.types[exts[i]] = type; } // Default extension is the first one we encounter if (!this.extensions[type]) { this.extensions[type] = exts[0]; } } }; /** * Load an Apache2-style ".types" file * * This may be called multiple times (it's expected). Where files declare * overlapping types/extensions, the last file wins. * * @param file (String) path of file to load. */ Mime.prototype.load = function(file) { this._loading = file; // Read file and split into lines var map = {}, content = fs.readFileSync(file, 'ascii'), lines = content.split(/[ ]+/); lines.forEach(function(line) { // Clean up whitespace/comments, and split into fields var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/); map[fields.shift()] = fields; }); this.define(map); this._loading = null; }; /** * Lookup a mime type based on extension */ Mime.prototype.lookup = function(path, fallback) { var ext = path.replace(/^.*[\.\/\\]/, '').toLowerCase(); return this.types[ext] || fallback || this.default_type; }; /** * Return file extension associated with a mime type */ Mime.prototype.extension = function(mimeType) { var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase(); return this.extensions[type]; }; // Default instance var mime = new Mime(); // Define built-in types mime.define(require('./types.json')); // Default type mime.default_type = mime.lookup('bin'); // // Additional API specific to the default instance // mime.Mime = Mime; /** * Lookup a charset based on mime type. */ mime.charsets = { lookup: function(mimeType, fallback) { // Assume text types are utf8 return (/^text\/|^application\/(javascript|json)/).test(mimeType) ? 'UTF-8' : fallback; } }; module.exports = mime;
Package URL License Primary language
pkg:npm/mime@1.6.0 mit JavaScript
pkg:npm/acme-demo-app@1.0.0 JavaScript