Installations
npm install sniffy-mimetype
Developer Guide
Typescript
No
Module System
ESM
Node Version
16.5.0
NPM Version
7.19.1
Score
71.4
Supply Chain
86.8
Quality
75.4
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
marcoscaceres
Download Statistics
Total Downloads
3,612
Last Day
1
Last Week
6
Last Month
41
Last Year
588
GitHub Statistics
2 Stars
10 Commits
3 Watching
2 Branches
1 Contributors
Bundle Size
2.15 kB
Minified
989.00 B
Minified + Gzipped
Package Meta Information
Latest Version
1.1.1
Package Id
sniffy-mimetype@1.1.1
Unpacked Size
11.23 kB
Size
3.61 kB
File Count
4
NPM Version
7.19.1
Node Version
16.5.0
Total Downloads
Cumulative downloads
Total Downloads
3,612
Last day
0%
1
Compared to previous day
Last week
50%
6
Compared to previous week
Last month
-41.4%
41
Compared to previous month
Last year
-25.6%
588
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
MIMEType
MIME Type string parser that tries to conform to the WHATWG MIME Sniff spec.
API
The MIMEType
class consists of:
constructor(string)
: takes a string representing a MIME type. This sends the string to the parser. If the string is non-conforming, it throws aTypeError
errors..essense
property: the "type", "/", and "subtype" normalized to lower case. For example: "text/plain"..type
: the primary type of the string. E.g., "application", "text", or "image"..subtype
: The subtype. So, like, "plain" in "text/plain"..parameters
: a Map consisting of the parameters that were passed, normalized per spec..toString()
: stringifier gives you back the MIME type in canonical form.
Exported utilty methods
isValidMimeType(string)
- returns boolean, checks if a MIME type is valid by parsing it.parseMimeType(string)
- returns an object{ type: string, subtype: string, params: object }
.
Examples
Creating and parsing
1// As a class 2import { MIMEType } from "MIMEType"; 3// Or utility functions 4import { isValidMimeType, parseMimeType } from "MIMEType"; 5 6const mimetype = new MIMEType("text/html; charset=UTF-8"); 7 8// This throws 9try { 10 new MIMEType("not valid"); 11} catch (err) { 12 // nice try... 13}
Accessing different parts
1import { MIMEType } from "MIMEType"; 2const mimetype = new MIMEType("text/html; charset=UTF-8"); 3console.log(mimetype.essense); // text/html 4console.log(mimetype.type) // text 5console.log(mimetype.subtype) // html
Parameters
Parameters is just a regular JavaScript Map, so:
1import { MIMEType } from "MIMEType"; 2const mimetype = new MIMEType("text/html; charset=UTF-8"); 3 4mimetype.parameters.has("charset"); // true 5 6for(const [key, value] of mimetype.parameters) { 7 console.log(key, value); 8}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
5 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-qrpm-p2h7-hrv2
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
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
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 1 are checked with a SAST tool
Score
2
/10
Last Scanned on 2024-12-30
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