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
Typescript
Module System
Min. Node Version
Node Version
NPM Version
92.2
Supply Chain
99.6
Quality
79
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
2,853,998
Last Day
746
Last Week
14,795
Last Month
59,508
Last Year
441,354
MIT License
10 Stars
184 Commits
1 Forks
3 Watchers
4 Branches
1 Contributors
Updated on Apr 01, 2025
Minified
Minified + Gzipped
Latest Version
5.0.3
Package Id
mime-type@5.0.3
Unpacked Size
408.80 kB
Size
52.82 kB
File Count
14
NPM Version
10.8.2
Node Version
20.18.0
Published on
Mar 27, 2025
Cumulative downloads
Total Downloads
Last Day
-11.6%
746
Compared to previous day
Last Week
-7.9%
14,795
Compared to previous week
Last Month
20%
59,508
Compared to previous month
Last Year
79.4%
441,354
Compared to previous year
The custom more powerful mime-type utility and built-in mime-db.
fork from mime-types, these features added:
mime = require('mime-type/with-db')
directlymime = 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: 2import { MimeType } from 'mime-type' 3const mime = new MimeType() 4//or using mimeType which create an instance and load builtin mime-db directly. 5import {mimeType} from 'mime-type/with-db' 6//it equals to (you need `npm install mime-db` first): 7import db from 'mime-db' 8const mime = new MimeType(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 duplication 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
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- 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 2025-06-23
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