@litert/mime
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

mime.js

License NPM stable version
GitHub releases GitHub issues

Get MIME type based on file name, path, and extension.

This repository doesn't require frequent updates, so even if it hasn't been updated for a long time, as long as it still exists, it means it's available. We'll keep an eye on whether it can function properly in the latest Node and browser environments.

Languages

简体中文 | 繁體中文 | 日本語

Installation

NPM

In the Node.js environment, you can install directly using NPM:

$ npm i @litert/mime --save

CDN

If you're using it in a browser, you can utilize the CDN mode.

<script src="https://cdn.jsdelivr.net/npm/@litert/loader@3.5.0/dist/loader.min.js?path=index&npm={'@litert/mime':'0.1.3'}"></script>

Usage

Demo code is written using TypeScript.

import * as mime from "@litert/mime";

mime.getData("hello.json");         // {"mime": "application/json", "compressible": true, extension: 'json'}
mime.getData(".html");              // {"mime": "text/html", "compressible": true, extension: 'html'}
mime.getData("css");                // {"mime": "text/css", "compressible": true, extension: 'css'}
mime.getData("hi/baby.js");         // {"mime": "application/javascript", "compressible": true, extension: 'js'}
mime.getData("/root/down/pk.zip");  // {"mime": "application/zip", "compressible": false, extension: 'zip'}
mime.getData("ext.dodooh");         // {"mime": "application/octet-stream", "compressible": false, extension: 'dodooh'}
mime.getMime("root/index.css");     // text/css

Test

Node

Once it's compiled correctly, you can run the sample code in the terminal by using node ./dist/test-node.

Browser

To view the examples, simply access the test/ directory in your browser.

Click here to view the examples online

License

This library is published under Apache-2.0 license.

Readme

Keywords

Package Sidebar

Install

npm i @litert/mime

Weekly Downloads

0

Version

0.1.3

License

Apache-2.0

Unpacked Size

99.5 kB

Total Files

10

Last publish

Collaborators

  • fenying
  • hanguoshuai