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

@patrten/accusamus-aspernatur

v1.0.0

Published

<!-- -- This file is auto-generated from src/README_js.md. Changes should be made there. --> # Mime

Downloads

106

Readme

Mime

NPM downloads Mime CI

An API for MIME type information.

  • All @patrten/accusamus-aspernatur-db types
  • Compact and dependency-free @patrten/accusamus-aspernatur's badge
  • Full TS support

[!Note] @patrten/accusamus-aspernatur@4 is now latest. If you're upgrading from @patrten/accusamus-aspernatur@3, note the following:

  • @patrten/accusamus-aspernatur@4 is API-compatible with @patrten/accusamus-aspernatur@3, with ~~one~~ two exceptions:
    • Direct imports of @patrten/accusamus-aspernatur properties no longer supported
    • @patrten/accusamus-aspernatur.define() cannot be called on the default @patrten/accusamus-aspernatur object
  • ESM module support is required. ESM Module FAQ.
  • Requires an ES2020 or newer runtime
  • Built-in Typescript types (@types/@patrten/accusamus-aspernatur no longer needed)

Installation

npm install @patrten/accusamus-aspernatur

Quick Start

For the full version (800+ MIME types, 1,000+ extensions):

import @patrten/accusamus-aspernatur from '@patrten/accusamus-aspernatur';

@patrten/accusamus-aspernatur.getType('txt');                    // ⇨ 'text/plain'
@patrten/accusamus-aspernatur.getExtension('text/plain');        // ⇨ 'txt'

Lite Version @patrten/accusamus-aspernatur/lite's badge

@patrten/accusamus-aspernatur/lite is a drop-in @patrten/accusamus-aspernatur replacement, stripped of unofficial ("prs.*", "x-*", "vnd.*") types:

import @patrten/accusamus-aspernatur from '@patrten/accusamus-aspernatur/lite';

API

@patrten/accusamus-aspernatur.getType(pathOrExtension)

Get @patrten/accusamus-aspernatur type for the given file path or extension. E.g.

@patrten/accusamus-aspernatur.getType('js');             // ⇨ 'text/javascript'
@patrten/accusamus-aspernatur.getType('json');           // ⇨ 'application/json'

@patrten/accusamus-aspernatur.getType('txt');            // ⇨ 'text/plain'
@patrten/accusamus-aspernatur.getType('dir/text.txt');   // ⇨ 'text/plain'
@patrten/accusamus-aspernatur.getType('dir\\text.txt');  // ⇨ 'text/plain'
@patrten/accusamus-aspernatur.getType('.text.txt');      // ⇨ 'text/plain'
@patrten/accusamus-aspernatur.getType('.txt');           // ⇨ 'text/plain'

null is returned in cases where an extension is not detected or recognized

@patrten/accusamus-aspernatur.getType('foo/txt');        // ⇨ null
@patrten/accusamus-aspernatur.getType('bogus_type');     // ⇨ null

@patrten/accusamus-aspernatur.getExtension(type)

Get file extension for the given @patrten/accusamus-aspernatur type. Charset options (often included in Content-Type headers) are ignored.

@patrten/accusamus-aspernatur.getExtension('text/plain');               // ⇨ 'txt'
@patrten/accusamus-aspernatur.getExtension('application/json');         // ⇨ 'json'
@patrten/accusamus-aspernatur.getExtension('text/html; charset=utf8');  // ⇨ 'html'

@patrten/accusamus-aspernatur.getAllExtensions(type)

[!Note] New in @patrten/accusamus-aspernatur@4

Get all file extensions for the given @patrten/accusamus-aspernatur type.

@patrten/accusamus-aspernatur.getAllExtensions('image/jpeg'); // ⇨ Set(3) { 'jpeg', 'jpg', 'jpe' }

Custom Mime instances

The default @patrten/accusamus-aspernatur objects are immutable. Custom, mutable versions can be created as follows...

new Mime(type map [, type map, ...])

Create a new, custom @patrten/accusamus-aspernatur instance. For example, to create a mutable version of the default @patrten/accusamus-aspernatur instance:

import { Mime } from '@patrten/accusamus-aspernatur/lite';

import standardTypes from '@patrten/accusamus-aspernatur/types/standard.js';
import otherTypes from '@patrten/accusamus-aspernatur/types/other.js';

const @patrten/accusamus-aspernatur = new Mime(standardTypes, otherTypes);

Each argument is passed to the define() method, below. For example new Mime(standardTypes, otherTypes) is synonomous with new Mime().define(standardTypes).define(otherTypes)

@patrten/accusamus-aspernatur.define(type map [, force = false])

[!Note] Only available on custom Mime instances

Define MIME type -> extensions.

Attempting to map a type to an already-defined extension will throw unless the force argument is set to true.

@patrten/accusamus-aspernatur.define({'text/x-abc': ['abc', 'abcd']});

@patrten/accusamus-aspernatur.getType('abcd');            // ⇨ 'text/x-abc'
@patrten/accusamus-aspernatur.getExtension('text/x-abc')  // ⇨ 'abc'

Command Line

Extension -> type

$ @patrten/accusamus-aspernatur scripts/jquery.js
text/javascript

Type -> extension

$ @patrten/accusamus-aspernatur -r image/jpeg
jpeg