パッケージの詳細

mime-explorer

Tada5hi626MIT1.1.0

This is a library for mime types. It provides an ESM and CJS build.

mime, mime-type, mime-types, extesnion

readme

mime-explorer ☂

npm version main codecov Known Vulnerabilities semantic-release: angular

A versatile library that simplifies MIME type management, providing a user-friendly interface to effortlessly retrieve MIME types based on file paths/extensions, gather comprehensive meta information, and obtain standard file extensions for a given MIME type.

It is well-suited for a variety of tasks, including seamless interaction with HTTP headers and general operations involving files.

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.

更新履歴

1.1.0 (2023-11-26)

Features

  • bump (dev-) dependencies (6d0915f)

1.0.0 (2023-01-12)

Bug Fixes

  • extended type information + added README.md section (d0fc503)
  • typescript type generation (238d3b6)

Features

1.0.2 (2023-01-12)

Bug Fixes

  • typescript type generation (238d3b6)

1.0.1 (2023-01-12)

Bug Fixes

  • extended type information + added README.md section (d0fc503)

1.0.0 (2023-01-12)

Features