Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
node-mime-types
Advanced tools
Changelog
1.1.2 - delivery @07/06/2023
Readme
A Node.js and zero-dependencies MIME type utility.
This library is powered by mime-db data. It provides a very simple, lightweight, safe yet speed utility to deal with MIME types and file extensions.
Supports 1180 file extensions and 965 MIME types.
npm install node-mime-types
npm i -S node-mime-types
Code style follows Airbnb JavaScript Best Practices using ESLint.
Uses Mocha and Chai for unit testing.
npm audit
.const mime = require('node-mime-types');
// mime is an object of functions
const {
getExtension,
getMIMEType,
} = require('node-mime-types');
node-mime-types module exports an object of functions. You'll find the complete list of functions below.
mime
<Object> with the following functions.Returns the file extension(s) based on the MIME type.
Note:
mimeType
<String>''
Examples:
getExtension(); // ''
getExtension(false); // ''
getExtension(''); // ''
getExtension('application/unknown'); // ''
getExtension('application/json5'); // '.json5'
getExtension('application/rtf'); // '.rtf'
getExtension('text/plain'); // ['.txt', '.text', '.conf', '.def', '.list', '.log', '.in', '.ini']
getExtension('application/json'); // ['.json', '.map']
getExtension('IMAGE/PNG'); // '.png'
Returns the MIME type based on the file name or path extension.
Note:
filenameOrPath
<String>application/octet-stream
Examples:
getMIMEType(); // ''
getMIMEType([]); // ''
getMIMEType(''); // ''
getMIMEType('f'); // 'application/octet-stream'
getMIMEType('file.unknown'); // 'application/octet-stream'
getMIMEType('.js'); // 'application/octet-stream'
getMIMEType('file.html'); // 'text/html'
getMIMEType('file.css'); // 'text/css'
getMIMEType('/usr/file.json'); // 'application/json'
getMIMEType('/usr/file.json.txt'); // 'text/plain'
getMIMEType('C:\\file.JS'); // 'application/javascript'
getMIMEType('../../path/to/file-name.XML'); // 'text/xml'
getMIMEType('README.md'); // 'text/markdown'
This project has a Code of Conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
If you find any MIME type or file extension missing, please directly contribute to mime-db.
Please take also a moment to read our Contributing Guidelines if you haven't yet done so.
Uses prettier
to format source code.
npm run format
npm run lint
npm run lint:fix
npm test
Extensions by MIME type and MIME types by extension files.
NOTE:
src
right after building files;npm run build
Please see our Support page if you have any questions or for any help needed.
For any security concerns or issues, please visit our Security Policy page.
MIT.
FAQs
A Node.js and zero-dependencies MIME type utility
The npm package node-mime-types receives a total of 11,734 weekly downloads. As such, node-mime-types popularity was classified as popular.
We found that node-mime-types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.