A file extension to MIME type module. Uses mime-db data but with zero dependencies.
npm install mimer
or npx mimer <file>
.
const mimer = require('mimer');
mimer('.pdf'); // -> "application/pdf"
mimer('pdf'); // -> "application/pdf"
mimer('../readme.pdf'); // -> "application/pdf"
mimer('pedefe'); // -> "application/octet-stream"
const mimer = require('mimer');
const mimerMap = require('mimer/map');
mimerMap.get('pdf'); // -> "application/pdf"
mimerMap.set('graphql', 'application/graphql');
mimer('content.graphql'); // -> "application/graphql"
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"
npm install -g mimer
mimer readme.pdf
or just
npx mimer readme.pdf
Just create a new Github Codespace or:
$ git clone https://github.com/data-uri/mimer.git
$ cd mimer
$ npm i
$ npm test
MIT License (c) Helder Santana