1.0.0 • Published 7 months ago

common-mime-types v1.0.0

Weekly downloads
-
License
Unlicense
Repository
github
Last release
7 months ago

Common MIME Types

Npm Bundlephobia Coverage Typescript License Npm download

A lightweight TypeScript/JavaScript library for handling common web MIME types. The MIME type definitions are sourced from MDN Web Docs - Common MIME Types.

Features

  • 🎯 Includes most commonly used MIME types on the web
  • 🔄 Bidirectional conversion between file extensions and MIME types
  • 📦 Lightweight with zero dependencies
  • 💪 Written in TypeScript with full type support

Usage

import { mimeTypes, mime2ext, ext2mime } from 'common-mime-types'

// Convert MIME type to file extension
const ext = mime2ext('image/png') // Returns '.png'

// Convert file extension to MIME type
const mimeType = ext2mime('.png') // Returns 'image/png'

// Search in mimeTypes array
mimeTypes.find((m) => m.mime === 'image/png')?.ext
mimeTypes.find((m) => m.ext === '.png')?.mime
1.0.0

7 months ago

0.1.0

7 months ago

0.0.1

7 months ago