npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mime-db-lite

v2.1.1

Published

A tiny, lightweight JavaScript API to query mime-db (Media-type / MIME-type database).

Readme

mime-db-lite

NPM Version JavaScript Test Publish NPM package

A tiny, lightweight, portable JavaScript module to query the complete mime-db (a popular Media-type / MIME-type / Content-type database). Data is actually sourced from mime-db-cdn, which mirrors mime-db with added features.

🚀 Consumes less run-time memory by fetching data as and when needed, with optional caching. Ideal for low footprint applications.

🚀 Cross-platform: Runs on browsers, server-side (e.g. NodeJS) or serverless (e.g. Cloudflare Workers V8 isolates).

🚀 Standard: ESM.

🚀 Promise-based; exports async methods.

🚀 Accepts custom fetch() method, if any.

Install and import

For browsers:

<script type="module">
    import DB from 'https://cdn.jsdelivr.net/npm/[email protected]/index.min.js';
    // Above, replace 2.0.0 with the actual version you'd be using, or use 'latest'
    
    // Your code here ...
</script>

For Node.js:

Install as

npm install mime-db-lite

Import as

import DB from 'mime-db-lite';

Instantiation, custom fetch() and LRU cache

Create an instance of the imported DB class to use the fetch() API provided by the runtime and forgo caching.

👉 For browsers, the native fetch() will still use the HTTP-cache.

const db = new DB();

To use an in-memory cache, instantiate as:

const db = new DB({ cacheMaxEntries: <Integer> });

<Integer> denotes the maximum number of entries the cache can store, beyond which the LRU entries will be evicted to make just enough space.

👉 Using an LRU cache claims more run-time memory in return for faster lookups. For browsers this may be unnecessary, because browser-native fetch() already uses HTTP-cache by default.

To use a custom fetch() method, e.g. async function custFetch (url) { ... }, instantiate as:

const db = new DB({ fetch: custFetch });

or, use an arrow function

const db = new DB({
    fetch: async (url) => {
        // Your code here
    } 
});

API

db.mimeToExtensions(mimeType) or its alias db.getExtensions(mimeType)

Returns a promise that fulfills with an array of file-extensions.

mimeType

String representing a MIME-type with structure:

type/subtype

type/subtype;parameter=value

👉 The returned promise is rejected with Not Found error if the provided mimeType is unavailable in mime-db.

Examples:

console.log(await db.mimeToExtensions('application/mp4'));
// Prints [ 'mp4', 'mpg4', 'mp4s', 'm4p' ]

console.log(await db.getExtensions('application/javascript; charset=utf-8'));
// Prints [ 'js' ]

db.extensionToMimes(extension) or its alias db.getTypes(extension)

Returns a promise that fulfills with an array of MIME-types. Note that this array of MIME-types is sorted in descending order of importance according to the same logic used by mime-types. If only one MIME-type is required, simply choose the first element from the array, or use the db.getType() method.

extension

String representing either of

  • path, e.g. dir/subdir/file.ext
  • file-extension with or without the leading dot, e.g. mp4, .mp4
  • file-name, e.g. file.mp4, file.version.1.2.0.mp4

👉 The returned promise is rejected with Not Found error if the provided mimeType is unavailable in mime-db.

Examples:

console.log(await db.extensionToMimes('dir/subdir/path.version.js'));

console.log(await db.getTypes('js'));

console.log(await db.getTypes('.js'));

// Prints [ 'application/javascript', 'text/javascript' ]

db.extensionToMime(extension) or its alias db.getType(extension)

Same as db.getTypes() above but the returned promise resolves with only a single MIME-type instead of an array. The returned MIME-type has the highest score according to the logic used by mime-types.

Examples:

console.log(await db.getType('.deb'));
// Prints 'application/x-debian-package'

db.query(mimeType)

Returns a promise that fulfills with the mime-db data object for the provided MIME-type.

mimeType

String representing a MIME-type in the form: type/subtype

👉 The returned promise is rejected with Not Found error if the provided mimeType is unavailable in mime-db.

Examples:

console.log(JSON.stringify(await db.query('application/javascript')));
// Prints '{"source":"apache","charset":"UTF-8","compressible":true,"extensions":["js"]}'

DB.mimeDbCdnVersion

A constant that stores the mime-db-cdn release version data is fetched from.

DB.cdnBase

A constant that stores the CDN via which data is accessed.

Contribute

To register new media types in the database, contribute directly to mime-db.

If you like this project, you can show your appreciation by

Sponsor

Thank you 💚.