Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
The 'mimer' npm package is a utility for determining the MIME type of a file based on its extension. It is useful for applications that need to handle files and their types, such as web servers, file upload handlers, and content management systems.
Determine MIME type from file extension
This feature allows you to get the MIME type of a file by providing its filename or extension. In this example, 'example.txt' returns 'text/plain'.
const mimer = require('mimer');
const mimeType = mimer('example.txt');
console.log(mimeType); // Output: 'text/plain'
Default MIME type for unknown extensions
If the file extension is not recognized, 'mimer' returns a default MIME type, which is 'application/octet-stream' in this case.
const mimer = require('mimer');
const mimeType = mimer('example.unknown');
console.log(mimeType); // Output: 'application/octet-stream'
The 'mime' package is a comprehensive MIME type utility that can look up MIME types based on file extensions and vice versa. It also allows for custom MIME type definitions. Compared to 'mimer', 'mime' offers more extensive functionality and a larger database of MIME types.
The 'mime-types' package provides a similar functionality to 'mimer' but with a more extensive list of MIME types and additional features like looking up extensions based on MIME types. It is more feature-rich and widely used in the community.
The 'mime-db' package is a database of MIME types mapped to file extensions. It is used by other packages like 'mime' and 'mime-types' to provide their functionality. While 'mime-db' itself is not a utility, it serves as the backbone for MIME type lookups in other packages.
A simple MIME type getter built on top of Node.js.
Browser version:: Minified (amd and CommonJS ready) Source
Node.js version: npm install mimer
into your project
// node and browserify
const Mimer = require('mimer');
// amd (Require.js and etc)
require('path/to/mimer', function (Mimer) {});
// browser (through script tag)
window.Mimer
Mimer('file.css'); // => "text/css"
// or
var mime = new Mimer();
mime.get('file.css'); // => "text/css"
var mime = new Mimer();
mime.set('.monster', 'movie/thriller')
.get('zombie.monster');
// => "movie/thriller"
mime.set(['.rctycoon','.simcity'], 'cms/game');
mime.get('/land/park.rctycoon'); // => "cms/game"
mime.get('maps/city.simcity'); // => "cms/game"
npm install -g mimer
(it may require Root privileges)
$ mimer brand.png
$ npm i
$ npm test
Build web version with:
$ npm run build
See more in Releases section.
MIT License (c) Helder Santana
FAQs
A simple Mime type getter
The npm package mimer receives a total of 138,900 weekly downloads. As such, mimer popularity was classified as popular.
We found that mimer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.