{"library":"mime-lite","title":"MIME Type Utilities (Lite)","description":"mime-lite provides a lightweight, standard set of MIME type mappings for JavaScript applications, suitable for both Node.js and browser environments. The current stable version is 1.0.3, with a release cadence that appears to be low but active, incorporating updates for new MIME types as needed (e.g., adding 'xls' in v1.0.3). Its key differentiator is being a 'lite' version, implying a smaller bundle size and a focused set of standard MIME type definitions compared to larger, more comprehensive libraries like the original `mime` package, from which it acknowledges copying its data. This makes it an efficient choice for projects where minimizing footprint is critical. It ships with TypeScript types, enhancing developer experience and type safety.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mime-lite"],"cli":null},"imports":["import { getType } from 'mime-lite';","import { getExtension } from 'mime-lite';","import * as MimeLite from 'mime-lite';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { getType, getExtension } from 'mime-lite';\n\n// Get MIME type from file extensions\nconst mimePdf = getType('document.pdf');\nconsole.log(`PDF MIME type: ${mimePdf}`); // Expected: application/pdf\n\nconst mimeJpeg = getType('image.jpeg');\nconsole.log(`JPEG MIME type: ${mimeJpeg}`); // Expected: image/jpeg\n\nconst mimeUnknown = getType('archive.xyz');\nconsole.log(`Unknown extension MIME type: ${mimeUnknown}`); // Expected: undefined or null\n\n// Get file extension from MIME types\nconst extHtml = getExtension('text/html');\nconsole.log(`HTML extension: ${extHtml}`); // Expected: html\n\nconst extJson = getExtension('application/json');\nconsole.log(`JSON extension: ${extJson}`); // Expected: json\n\nconst extUnsupported = getExtension('application/x-custom');\nconsole.log(`Unsupported MIME extension: ${extUnsupported}`); // Expected: undefined or null\n\n// Example: Basic file type validation\nfunction isCommonTextFile(fileName: string): boolean {\n  const mime = getType(fileName);\n  return ['text/plain', 'text/html', 'application/json', 'text/css', 'text/javascript'].includes(mime ?? '');\n}\n\nconsole.log(`'report.txt' is a common text file: ${isCommonTextFile('report.txt')}`);\nconsole.log(`'image.png' is a common text file: ${isCommonTextFile('image.png')}`);","lang":"typescript","description":"Demonstrates basic usage of `getType` and `getExtension` to determine MIME types from extensions and vice versa, including a simple validation example.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}