Skip to content

data-uri/mimer

Repository files navigation

Mimer Build Status install size

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

License

MIT License (c) Helder Santana