mimer
v2.0.2
Published
A simple Mime type getter
Downloads
1,032,918
Readme
Mimer
A file extension to MIME type module. Uses mime-db data but with zero dependencies.
Getting started
npm install mimer
or npx mimer <file>
.
Module
const mimer = require('mimer');
mimer('.pdf'); // -> "application/pdf"
mimer('pdf'); // -> "application/pdf"
mimer('../readme.pdf'); // -> "application/pdf"
mimer('pedefe'); // -> "application/octet-stream"
Extension Map
const mimer = require('mimer');
const mimerMap = require('mimer/map');
mimerMap.get('pdf'); // -> "application/pdf"
mimerMap.set('graphql', 'application/graphql');
mimer('content.graphql'); // -> "application/graphql"
Safe mode
In case you want to avoid changes on original Map for safety.
const mimer = require('mimer/safe');
const mimerMap = require('mimer/map');
mimerMap.set('graphql', 'application/graphql');
mimer('content.graphql'); // -> "application/octet-stream"
CLI
npm install -g mimer
mimer readme.pdf
or just
npx mimer readme.pdf
Contribute
Just create a new Github Codespace or:
$ git clone https://github.com/data-uri/mimer.git
$ cd mimer
$ npm i
$ npm test
Changelog.
License
MIT License (c) Helder Santana