Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 modern browser, you can import the package as a native ES module from a CDN.

<script type="module">
    import * as mime from "https://cdn.jsdelivr.net/npm/@litert/mime@2.0.0/dist/index.js";

    console.log(mime.getMime("index.css"));
</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": "text/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.

About

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

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages