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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mimoza

v1.0.0

Published

Simple mime-types tools library

Downloads

13,004

Readme

Mimoza

Build Status NPM version Coverage Status

Mimoza is a tiny but comprehensive MIME tools library. Features:

  • Resolving mime type by file path/name/extention (with fallback for unknown cases).
  • Finding file extention by mime type.
  • Checking if mime type (or file) can be compressed.
  • Checking if mime type has text content (if you wish to force UTF-8 encoding)
  • You can have multimple instances with different configs.
  • Works in browser too (AMD module).

See detailed API docs.

Installation

for node.js:

npm install mimoza

for browser (AMD module):

bower install mimoza

Example

var Mimoza = require('mimoza');

// Use builtin methods:

Mimoza.getExtension('audio/ogg');       // -> '.oga'

Mimoza.getMimeType('ogg');              // -> 'audio/ogg'
Mimoza.getMimeType('.oga');             // -> 'audio/ogg'
Mimoza.getMimeType('test.oga');         // -> 'audio/ogg'
Mimoza.getMimeType('foo/bar.oga');      // -> 'audio/ogg'

Mimoza.isCompressible('text/html');                // -> true
Mimoza.isCompressible('application/octet-stream'); // -> false

Mimoza.isText('text/html');                // -> true
Mimoza.isText('application/javascript');   // -> true
Mimoza.isText('application/json');         // -> true
Mimoza.isText('application/octet-stream'); // -> false


// Define your own instance

var mime = new Mimoza({
  defaultType: 'hard/core', // mime type for unknown extentions
  preloaded: true           // load default rules
});

// instances are customizeable
mime.register('foo/bar', ['baz', 'moo']);

mime.getExtension('foo/bar');           // -> '.baz'
mime.getMimeType('baz');                // -> 'foo/bar'
mime.getMimeType('moo');                // -> 'foo/bar'

// unknown file types, with default & custom fallback
mime.getMimeType('tada');               // -> 'hard/core'
mime.getMimeType('tada', 'soft/core');  // -> 'soft/core'