{"library":"mime-lookup","title":"MIME Type Lookup Utility","description":"The `mime-lookup` library provides a focused utility for resolving MIME types based on file extensions. Unlike some alternatives, this package does not bundle its own MIME type database. Instead, it requires the user to supply a database, typically by integrating with the `mime-db` package. As of its only released version, 0.0.2, it offers core functionalities such as `lookup` for determining a MIME type from a given path, `extension` for retrieving a default file extension from a MIME type, and `define` for adding custom MIME type to extension mappings. It also includes `charsets.lookup` for charset mappings. Key differentiators include its lightweight nature due to the decoupled database, allowing for flexible custom database integration. First published in 2015 and last updated in 2016, the project appears to be unmaintained, making its release cadence non-existent.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install mime-lookup"],"cli":null},"imports":["const MimeLookup = require('mime-lookup');","const mimeDb = require('mime-db');","const mime = new MimeLookup(require('mime-db'));"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const MimeLookup = require('mime-lookup');\nconst mimeDb = require('mime-db'); // This is the recommended database\n\n// Initialize MimeLookup with the mime-db database\nconst mime = new MimeLookup(mimeDb);\n\nconsole.log('--- MIME Type Lookups ---');\nconsole.log('file.txt:', mime.lookup('file.txt'));\nconsole.log('image.jpeg:', mime.lookup('image.jpeg'));\nconsole.log('.html:', mime.lookup('.html'));\nconsole.log('unknown.xyz (default):', mime.lookup('unknown.xyz'));\n\nconsole.log('\\n--- Extension Lookups ---');\nconsole.log('text/html:', mime.extension('text/html'));\nconsole.log('application/json:', mime.extension('application/json'));\n\nconsole.log('\\n--- Custom Mappings ---');\nmime.define({\n    'application/x-custom-format': ['xcf', 'customfmt'],\n    'text/markdown': ['md', 'markdown']\n});\nconsole.log('document.xcf:', mime.lookup('document.xcf'));\nconsole.log('report.md:', mime.lookup('report.md'));\nconsole.log('application/x-custom-format (extension):', mime.extension('application/x-custom-format'));","lang":"javascript","description":"This quickstart demonstrates how to instantiate `MimeLookup` using `mime-db`, perform basic MIME type lookups, retrieve extensions, and define custom MIME type mappings.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}