Gathering detailed insights and metrics for mime-matcher
Gathering detailed insights and metrics for mime-matcher
npm install mime-matcher
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
147,937
Last Day
657
Last Week
2,526
Last Month
9,412
Last Year
47,013
6 Stars
23 Commits
2 Forks
2 Watching
16 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.5
Package Id
mime-matcher@1.0.5
Unpacked Size
81.02 kB
Size
21.78 kB
File Count
19
NPM Version
6.12.1
Node Version
12.13.1
Cumulative downloads
Total Downloads
Last day
5%
657
Compared to previous day
Last week
-24.8%
2,526
Compared to previous week
Last month
7.4%
9,412
Compared to previous month
Last year
156.6%
47,013
Compared to previous year
25
MimeMatcher is very simple library for checking if mime type string is in allowed range.
You can also match mime types against wildcards, like */*
or 'application/*'
You can install it from npm:
npm install mime-matcher --save
Or you can download mime-matcher.min.js
from the dist folder and then include it in html file:
1<script src="mime-matcher.min.js"></script>
1import MimeMatcher from 'mime-matcher' 2 3const matcher = new MimeMatcher('image/gif') 4 5matcher.match('image/gif') //true 6matcher.match('image/jpeg') //false
You can also use wildcards:
1import MimeMatcher from 'mime-matcher' 2 3new MimeMatcher('image/*').match('image/gif') //true 4new MimeMatcher('*/*').match('text/xml') //true 5
You can also use multiple mime types to match against:
1import MimeMatcher from 'mime-matcher' 2 3const matcher = new MimeMatcher('image/*', 'text/*') 4 5matcher.match('text/xml') //true 6matcher.match('image/gif') //true 7matcher.match('audio/mpeg') //false 8
Optional mime type parameter is ignored:
1import MimeMatcher from 'mime-matcher' 2 3const matcher = new MimeMatcher('text/xml') 4 5matcher.match('text/xml; encoding=utf-8') //true
You can also use higher-order function matcher
, which accepts expected types and returns another function, which you can use for matching:
1import { matcher } from 'mime-matcher' 2 3const m = matcher('text/*') 4m('text/xml') //true 5 6matcher('image/*', 'text/*')("image/gif") //true
There is also function parse
which returns object containing data of parsed mime-type:
1import { parse as parseMimeType } from 'mime-matcher' 2 3parseMimeType('application/json') 4/* 5{ 6 valid: true 7 type: "application", 8 subType: "json" 9} 10*/ 11 12parseMimeType('text/xml; encoding=utf-8') 13/* 14{ 15 valid: true 16 type: "text", 17 subType: "xml", 18 parameter: "encoding=utf-8" 19} 20*/ 21 22 23parseMimeType('invalid') 24/* 25{ 26 valid: false 27} 28*/ 29
You can also import function isValid
as shorthand for checking validity:
1import { isValid as isValidMimeType } from 'mime-matcher' 2 3isValidMimeType('text/xml') //true 4
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/9 approved changesets -- score normalized to 0
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
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
80 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-20
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