{"name":"mrmime","version":"2.0.1","repository":{"type":"git","url":"git+https://github.com/lukeed/mrmime.git"},"description":"A tiny (2.8kB) and fast utility for getting a MIME type from an extension or filename","module":"index.mjs","types":"index.d.ts","main":"index.js","license":"MIT","author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"https://lukeed.com"},"exports":{".":{"types":"./index.d.ts","import":"./index.mjs","require":"./index.js"},"./package.json":"./package.json"},"engines":{"node":">=10"},"scripts":{"build":"tsm bin/index.ts","test":"uvu -r tsm test"},"keywords":["mime","extension","mimetype"],"devDependencies":{"tsm":"2.3.0","uvu":"0.5.2"},"_id":"mrmime@2.0.1","gitHead":"c95e4bf5ac71e7847c7e74d409e237a37c7b5053","bugs":{"url":"https://github.com/lukeed/mrmime/issues"},"homepage":"https://github.com/lukeed/mrmime#readme","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==","shasum":"bc3e87f7987853a54c9850eeb1f1078cd44adddc","tarball":"http://registry-npm.ywwl.com/mrmime/download/mrmime-2.0.1.tgz","fileCount":6,"unpackedSize":33008,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICDRrPyK816R1ZljZE0eenrwfzk8E7HPtREkQkE53d8XAiBde1otP0Ef2bbZ2gKor1T2+fp9U4fTW3/6qE1AdPwtvw=="}],"size":6358,"noattachment":false,"key":"/mrmime/-/mrmime-2.0.1.tgz"},"_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mrmime_2.0.1_1739816224943_0.6970574894840189"},"_hasShrinkwrap":false,"readme":"<div align=\"center\">\n  <img src=\"logo.png\" alt=\"mrmime\" width=\"320\" />\n</div>\n\n<div align=\"center\">\n  <a href=\"https://npmjs.org/package/mrmime\">\n    <img src=\"https://badgen.now.sh/npm/v/mrmime\" alt=\"version\" />\n  </a>\n  <a href=\"https://github.com/lukeed/mrmime/actions\">\n    <img src=\"https://github.com/lukeed/mrmime/workflows/CI/badge.svg\" alt=\"CI\" />\n  </a>\n  <a href=\"https://licenses.dev/npm/mrmime\">\n    <img src=\"https://licenses.dev/b/npm/mrmime\" alt=\"licenses\" />\n  </a>\n  <a href=\"https://npmjs.org/package/mrmime\">\n    <img src=\"https://badgen.now.sh/npm/dm/mrmime\" alt=\"downloads\" />\n  </a>\n  <a href=\"https://packagephobia.now.sh/result?p=mrmime\">\n    <img src=\"https://packagephobia.now.sh/badge?p=mrmime\" alt=\"install size\" />\n  </a>\n</div>\n\n<div align=\"center\">\n  A tiny (2.8kB) and fast utility for getting a MIME type from an extension or filename\n</div>\n\n\n## Features\n\n* Lightweight – 2.8kB gzip<br>\n  _Only includes standard mime types; all experimental and vendor-specific mimetypes removed._\n\n* [Performant](#benchmarks)<br>\n  _All lookups are O(1) with minimal processing._\n\n* Comprehensive Dictionary<br>\n  _Generated from [`mime-db`](https://github.com/jshttp/mime-db), which aggregates the IANA, NGINX, and Apache datasets._\n\n* Customizable<br>\n  _Exposes the `mimes` dictionary for easy additions or overrides._\n\n* Supports Native ESM and [Deno](https://deno.land/x/mrmime)<br>\n  _Ships with CommonJS and ESM support!_\n\n\n## Install\n\n```\n$ npm install --save mrmime\n```\n\n\n## Usage\n\n```js\nimport { lookup, mimes } from 'mrmime';\n\n// Get a MIME type\n// ---\nlookup('txt'); //=> \"text/plain\"\nlookup('.txt'); //=> \"text/plain\"\nlookup('a.txt'); //=> \"text/plain\"\n\n// Unknown extension\n// ---\nlookup('.xyz'); //=> undefined\n\n// Add extension to dictionary\n// ---\nmimes['xyz'] = 'hello/world';\nlookup('xyz'); //=> \"hello/world\"\n```\n\n\n## API\n\n### lookup(input)\nReturns: `string` or `undefined`\n\n#### input\nType: `string`\n\nThe extension or filename to lookup.\n\n> **Important:**\n>   * Any `input` value is cast to string, lowercased, and trimmed.\n>   * If a filename or filepath is provided, only the extension will be used.\n\n\n## Benchmarks\n\n> Running on Node v16.8.0\n\n```\nLoad times:\n  mrmime     0.963ms\n  mime/lite  3.281ms\n  mime       6.751ms\n\nBenchmark :: plain (\"ext\")\n  mime          x 598,849 ops/sec ±0.28% (94 runs sampled)\n  mime/lite     x 536,643 ops/sec ±0.11% (97 runs sampled)\n  mrmime        x 835,885 ops/sec ±0.20% (97 runs sampled)\n\nBenchmark :: leading (\".ext\")\n  mime          x 368,656 ops/sec ±0.19% (99 runs sampled)\n  mime/lite     x 368,318 ops/sec ±0.13% (97 runs sampled)\n  mrmime        x 533,643 ops/sec ±0.10% (96 runs sampled)\n\nBenchmark :: filename (\"file.ext\")\n  mime          x 326,907 ops/sec ±0.17% (95 runs sampled)\n  mime/lite     x 327,479 ops/sec ±0.12% (98 runs sampled)\n  mrmime        x 512,823 ops/sec ±0.12% (99 runs sampled)\n```\n\n\n## Credits\n\nOf course, a thank-you to [`mime`](https://github.com/broofa/mime) serving the community all these years & for being a all-encompassing MIME type library. I've only ever needed lookup/`getType` functionality – and now ESM support – so `mrmime` can only ever support 1/3 of what `mime` offers, at best.\n\nThis would not be possible without the team behind [`mime-db`](https://github.com/jshttp/mime-db), who have painstakingly maintained an amazing database for 7+ years.\n\nArtwork created by [mintinol](https://www.deviantart.com/mintinol), which I found [here](https://www.deviantart.com/mintinol/art/Mr-Mime-373927920).\n\nFinally, thanks to [Tim Branyen](https://github.com/tbranyen) for donating the package name :)\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","publish_time":1739816225137,"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_cnpm_publish_time":1739816225137,"dist-tags":{"latest":"2.0.1"}}