Gathering detailed insights and metrics for mime-type
Gathering detailed insights and metrics for mime-type
Gathering detailed insights and metrics for mime-type
Gathering detailed insights and metrics for mime-type
npm install mime-type
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
7 Stars
158 Commits
3 Watching
3 Branches
1 Contributors
Updated on 05 Sept 2024
Minified
Minified + Gzipped
JavaScript (68.22%)
CoffeeScript (31.78%)
Cumulative downloads
Total Downloads
Last day
-21.3%
2,338
Compared to previous day
Last week
9.7%
16,011
Compared to previous week
Last month
22.6%
54,728
Compared to previous month
Last year
10.8%
343,887
Compared to previous year
The custom more powerful mime-type utility can work with mime-db.
fork from mime-types, these features added:
mime = new Mime(require('mime-db'))
mime = require('mime-type/with-db')
directly, but firstnpm install mime-db
mime = new Mime()
business, so you could do lookup = mime.lookup.bind(mime)
..lookup(extention)
functionality.define(type, mime)
functionality.load(mimes)
functionality.glob(pattern)
functionality.delete(type)
functionality.clear(filter)
functionality.exist(type)
functionality to check whether a mime-type is exist..extensions
will be deprecated, use mime[type].extensions
instead.undefined
if input is invalid or not found.Otherwise, the API is compatible.
1$ npm install mime-type
1//create an empty mime-type: 2var mime = require('mime-type')() 3//or create an instance and load mime-db. you need `npm install mime-db` 4var mime = require('mime-type/with-db') 5//it equals to: 6var db = require('mime-db') 7var mime = require('mime-type')(db)
All functions return undefined
if input is invalid or not found.
Lookup the content-type associated with a file.
1mime.lookup('json') // 'application/json' 2mime.lookup('.md') // 'text/x-markdown' 3mime.lookup('file.html') // 'text/html' 4mime.lookup('folder/file.js') // 'application/javascript' 5mime.lookup('folder/.htaccess') // false 6 7mime.lookup('.og?') // [ 'application/ogg', 'audio/ogg', 'audio/ogg', 'video/ogg' ] 8mime.lookup('cats') // false
Return all MIME types which matching a pattern(See Minimatch).
1mime.glob('*/*') // ['application/octet-stream'] 2mime.glob('*/*markdown') // ['text/x-markdown'] 3mime.glob('text/j*') // ['text/jade', 'text/jsx'] 4mime.glob('unknown/x') // []
test whether a mime-type is exist.
It is an alias for mime.hasOwnProperty
1mime.exist('text/x-markdown') // true 2mime.exist('unknown/xxx') // false
define a new mime-type. the duplicationWay is optional the process way of duplication extensions:
return the added extensions list if successful or undefined
.
1mime.define('script/coffee', { 2 extensions: ['coffee', 'litcoffee', 'coffee.md'] 3}, mime.dupAppend) 4mime.lookup ('coffee') //[ 'text/coffeescript', 'script/coffee' ]
remove a specified mime-type
1mime.delete('script/coffee') //true
clear all or specified mime-types
the filter could be a string pattern or a function
return the count of deleted mime-types.
1mime.clear() //clear all mime-types 2mime.clear('text/*') //clear the specified mime-types 3mime.clear(function(type, mime){ 4 return type.substr(0,5) === 'text/' 5})
load a lot of mime-types. return the count of loaded mime-types.
1mime.clear() //clear all mime-types 2mime.load({ 3 'script/coffee': { 4 extensions: ['coffee', 'coffee.md', 'litcoffee'], 5 compressible: true, 6 charset: 'utf-8', 7 defaultExtension: 'coffee.md' 8 }, 9 'script/python': { 10 extensions: ['py', 'py.md', 'litpy'], 11 compressible: true, 12 charset: 'utf-8' 13 } 14})
Create a full content-type header given a content-type or extension.
1mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
2mime.contentType('file.json') // 'application/json; charset=utf-8'
3
4// from a full path
5mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
Get the default extension for a content-type.
1mime.extension('application/octet-stream') // 'bin'
Lookup the implied default charset of a content-type.
1mime.charset('text/x-markdown') // 'UTF-8'
A map of content-types by extension.
A map of extensions by content-type.
A map of mime object(IMimeType) by content-type.
1export interface IMimeType { 2 source: string; 3 charset?: string; 4 compressible?: boolean; 5 extensions: string[]|string; 6}
the default duplicationo process way.
See mime.define
.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More