0.1.3 • Published 12 months ago

@litert/mime v0.1.3

Weekly downloads
7
License
Apache-2.0
Repository
github
Last release
12 months ago

mime.js

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.

0.1.2

12 months ago

0.1.3

12 months ago

0.1.1

4 years ago

0.1.0

4 years ago