{"id":15608428,"url":"https://github.com/hypercubed/mime-lookup","last_synced_at":"2025-03-29T14:25:06.755Z","repository":{"id":57297210,"uuid":"42032648","full_name":"Hypercubed/mime-lookup","owner":"Hypercubed","description":"Comprehensive MIME type mapping API","archived":false,"fork":false,"pushed_at":"2015-11-23T12:28:38.000Z","size":140,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T06:59:44.541Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hypercubed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-07T05:15:55.000Z","updated_at":"2017-05-10T10:45:20.000Z","dependencies_parsed_at":"2022-09-01T08:41:30.820Z","dependency_job_id":null,"html_url":"https://github.com/Hypercubed/mime-lookup","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fmime-lookup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fmime-lookup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fmime-lookup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fmime-lookup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hypercubed","download_url":"https://codeload.github.com/Hypercubed/mime-lookup/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246194704,"owners_count":20738722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T05:20:48.622Z","updated_at":"2025-03-29T14:25:06.718Z","avatar_url":"https://github.com/Hypercubed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mime-lookup\n\nComprehensive MIME type mapping API based on [broofa/node-mime](https://github.com/broofa/node-mime) module.\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Hypercubed/mime-lookup/blob/master/LICENSE)\n\n## Difference from node-mime\n\n1. This module does not include a mime type database.  Either supply your own, as described below, or include [mime-db](https://github.com/jshttp/mime-db).\n2. No command line tool.  Since no mime types are included this is not possible using this API only module.\n3. `Mime.prototype.load` has been removed to avoid dependency on Node File System.\n4. Added 'glob' function to expand mime patterns by [APIs-guru](https://github.com/APIs-guru/node-mime).\n\n## Install\n\nInstall with [npm](http://github.com/isaacs/npm) (mime-db is optional):\n\n```bash\nnpm install mime-lookup mime-db\n```\n\n**mine-db is optional and only needed it you wish to use the mime-db mime-type database.**\n\n## Contributing / Testing\n\n```bash\nnpm test\n```\n\n## API\n\n### MimeLookup(db)\n\nThis module does not include the mime types database.  Either supply your own or include the [mime-db](https://github.com/jshttp/mime-db).  Construct a new mime type lookup service by supplying a mime type database.\n\n#### Using [mime-db](https://github.com/jshttp/mime-db)\n\n```js\nvar MimeLookup = require('mime-lookup');\nvar mime = new MimeLookup(require('mime-db'));\n```\n\n#### Using your own types\n```js\nvar MimeLookup = require('mime-lookup');\nvar mime = new MimeLookup(yourDb);\n```\n\nThe mime-type database can be formatted two ways:\n\n*Simple*\n```json\n{\n    \"text/x-some-format\": [\"x-sf\", \"x-sft\", \"x-sfml\"],\n    \"application/x-my-type\": [\"x-mt\", \"x-mtt\"]\n}\n```\n\n*Like mime-db*\n```json\n{\n  \"text/x-some-format\": {\n    \"source\": \"iana\",\n    \"extensions\": [\"x-sf\", \"x-sft\", \"x-sfml\"]\n  },\n  \"application/x-my-type\": {\n    \"source\": \"apache\",\n    \"extensions\": [\"x-mt\", \"x-mtt\"]\n  }\n}\n```\n\n**Note in this case only the \"extensions\" property is used**\n\n### mime.lookup(path)\n\nGet the mime type associated with a file, if no mime type is found `application/octet-stream` is returned. Performs a case-insensitive lookup using the extension in `path` (the substring after the last '/' or '.').  E.g.\n\n```js\nmime.lookup('file.txt');                  // =\u003e 'text/plain'\nmime.lookup('.TXT');                      // =\u003e 'text/plain'\nmime.lookup('htm');                       // =\u003e 'text/html'\n```\n\n### mime.default_type\n\nSets the mime type returned when `mime.lookup` fails to find the extension searched for\n\n### mime.extension(type)\nGet the default extension for `type`\n\n```js\nmime.extension('text/html');                 // =\u003e 'html'\nmime.extension('application/octet-stream');  // =\u003e 'bin'\n```\n\n### mime.charsets.lookup()\n\nMap mime-type to charset\n\n```js\nmime.charsets.lookup('text/plain');        // =\u003e 'UTF-8'\n```\n\n### mime.define()\n\nAdd additional custom mime/extension mappings\n\n```js\nmime.define({\n    'text/x-some-format': ['x-sf', 'x-sft', 'x-sfml'],\n    'application/x-my-type': ['x-mt', 'x-mtt'],\n    // etc ...\n});\n\nmime.lookup('x-sft');                 // =\u003e 'text/x-some-format'\n```\n\nThe first entry in the extensions array is returned by `mime.extension()`. E.g.\n\n```js\nmime.extension('text/x-some-format'); // =\u003e 'x-sf'\n```\n\n## Acknowledgements\n\nThis code is based on [broofa/node-mime](https://github.com/broofa/node-mime) with additions from  [APIs-guru](https://github.com/APIs-guru/node-mime).\n\n## License\n\nOriginal work Copyright (c) 2010 Benjamin Thomas, Robert Kieffer\nModified work Copyright 2015 Jayson Harshbarger\n\n[MIT License](https://github.com/Hypercubed/mime-lookup/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypercubed%2Fmime-lookup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypercubed%2Fmime-lookup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypercubed%2Fmime-lookup/lists"}