Installations
npm install mime-kind
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=10
Node Version
14.20.0
NPM Version
6.14.17
Score
97.3
Supply Chain
86.4
Quality
75.3
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
strikeentco
Download Statistics
Total Downloads
5,102,034
Last Day
4,082
Last Week
22,467
Last Month
83,384
Last Year
1,274,340
GitHub Statistics
9 Stars
22 Commits
2 Forks
2 Watching
6 Branches
1 Contributors
Bundle Size
180.32 kB
Minified
32.03 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.0.0
Package Id
mime-kind@4.0.0
Unpacked Size
8.67 kB
Size
3.32 kB
File Count
5
NPM Version
6.14.17
Node Version
14.20.0
Total Downloads
Cumulative downloads
Total Downloads
5,102,034
Last day
-16.3%
4,082
Compared to previous day
Last week
-15.8%
22,467
Compared to previous week
Last month
-12.1%
83,384
Compared to previous month
Last year
1.9%
1,274,340
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
2
Dev Dependencies
6
mime-kind
Detect the MIME type of a Buffer
, Uint8Array
, ArrayBuffer
, ReadableStream
, file path and file name, with async
method.
Install
1$ npm install mime-kind --save
Usage
1const { createReadStream } = require('fs'); 2const mime = require('mime-kind'); 3 4await mime('.fakeext'); // -> null 5await mime(createReadStream('./anonim.jpg')); // -> { ext: 'jpeg', mime: 'image/jpeg' } 6await mime('c:/anonim.jpeg'); // -> { ext: 'jpeg', mime: 'image/jpeg' }
API
mime(input, [defaultValue])
mime.async(input, [defaultValue])
Returns a Promise
with an object (or null
when no match) with:
ext
- file typemime
- the MIME type
This methods supports all kind of ReadableStreams
.
Params:
- input (String|Buffer|Uint8Array|ArrayBuffer|ReadableStream) -
Buffer
,Uint8Array
,ArrayBuffer
,ReadableStream
, file path or file name. - [defaultValue] (String|Object) -
String
orObject
with value which will be returned if no match will be found. IfdefaultValue
is incorrect returnsnull
.
1const mime = require('mime-kind'); 2 3await mime('.fakeext', 'application/octet-stream'); // -> { ext: 'bin', mime: 'application/octet-stream' } 4await mime.async('.fakeext', { ext: 'mp4', mime: 'video/mp4' }); // -> { ext: 'mp4', mime: 'video/mp4' } 5await mime.async('.fakeext', 'ogg'); // -> { ext: 'ogg', mime: 'audio/ogg' } 6// but 7await mime.async('.fakeext', 'ogg3'); // -> null 8await mime('.fakeext', { ext: 'fake', mime: 'fake/fake' }); // -> null
With HTTP(S)
streams:
1const mime = require('mime-kind'); 2const { get } = require('https'); 3const { PassThrough } = require('stream'); 4 5const pass = new PassThrough(); 6get('https://avatars0.githubusercontent.com/u/2401029', res => res.pipe(pass)); 7await mime(pass); // -> { ext: 'jpg', mime: 'image/jpeg' }
License
The MIT License (MIT)
Copyright (c) 2015-2022 Alexey Bystrov
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/strikeentco/mime-kind/node.js.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/strikeentco/mime-kind/node.js.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/18 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/node.js.yml:1
- Info: no jobLevel write permissions found
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
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 4 are checked with a SAST tool
Reason
11 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Score
2.7
/10
Last Scanned on 2025-01-13
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