mime-explorer
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

mime-explorer

npm version main codecov Known Vulnerabilities semantic-release: angular

This is a library for mime types. It provides an ESM (136kb) and CJS (136kb) build.

Table of Contents

Installation

npm install mime-explorer --save

Usage

To get the mime type for a given path or extension:

import { getType } from 'mime-explorer';

getType('txt');
// => 'text/plain'

getType('json');
// => 'application/json'

To get the file extension for a given mime type:

import { getExtension } from 'mime-explorer';

getExtension('text/plain');
// => 'txt'

getExtension('application/json');
// => 'json'

To get meta information for a mime type:

import { get } from 'mime-explorer';

get('text/plain');
/*
{
    "source": "iana",
    "compressible": true,
    "extensions": [
        "txt",
        "text",
        "conf",
        "def",
        "list",
        "log",
        "in",
        "ini"
    ]
}
 */

get('application/json');
/*
{
    "source": "iana",
    "charset": "UTF-8",
    "compressible": true,
    "extensions": [
        "json",
        "map"
    ]
}
 */

License

Made with 💚

Published under MIT License.

Install

npm i mime-explorer

DownloadsWeekly Downloads

572

Version

1.0.0

License

MIT

Unpacked Size

295 kB

Total Files

10

Last publish

Collaborators

  • tada5hi