{"id":27843154,"url":"https://github.com/broofa/node-mime","last_synced_at":"2025-05-03T07:01:06.559Z","repository":{"id":37683146,"uuid":"534940","full_name":"broofa/mime","owner":"broofa","description":"Mime types for JavaScript","archived":false,"fork":false,"pushed_at":"2025-04-03T14:31:18.000Z","size":775,"stargazers_count":2246,"open_issues_count":0,"forks_count":318,"subscribers_count":20,"default_branch":"main","last_synced_at":"2025-05-01T18:03:34.247Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/broofa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["broofa"]}},"created_at":"2010-02-25T01:05:42.000Z","updated_at":"2025-04-24T23:20:33.000Z","dependencies_parsed_at":"2023-02-04T10:46:55.985Z","dependency_job_id":"7f9d7cf9-a0c8-4904-8bd5-5bdf93d9b56f","html_url":"https://github.com/broofa/mime","commit_stats":{"total_commits":317,"total_committers":56,"mean_commits":5.660714285714286,"dds":0.2902208201892744,"last_synced_commit":"cfa9bb0e17d02ee8fc8d1e514c3ded274c62245c"},"previous_names":["broofa/node-mime"],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broofa%2Fmime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broofa%2Fmime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broofa%2Fmime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/broofa%2Fmime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/broofa","download_url":"https://codeload.github.com/broofa/mime/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252154866,"owners_count":21702988,"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":"2025-05-03T07:00:40.969Z","updated_at":"2025-05-03T07:01:06.407Z","avatar_url":"https://github.com/broofa.png","language":"TypeScript","readme":"\u003c!--\n  -- This file is auto-generated from src/README_js.md. Changes should be made there.\n  --\u003e\n# Mime\n\n[![NPM downloads](https://img.shields.io/npm/dm/mime)](https://www.npmjs.com/package/mime)\n[![Mime CI](https://github.com/broofa/mime/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/broofa/mime/actions/workflows/ci.yml?query=branch%3Amain)\n\nAn API for MIME type information.\n\n- All `mime-db` types\n- Compact and dependency-free [![mime's badge](https://deno.bundlejs.com/?q=mime\u0026badge)](https://bundlejs.com/?q=mime)\n- Full TS support\n\n\n\u003e [!Note]\n\u003e `mime@4` is now `latest`.  If you're upgrading from `mime@3`, note the following:\n\u003e * `mime@4` is API-compatible with `mime@3`, with ~~one~~ two exceptions:\n\u003e   * Direct imports of `mime` properties [no longer supported](https://github.com/broofa/mime/issues/295)\n\u003e   * `mime.define()` cannot be called on the default `mime` object\n\u003e * ESM module support is required.   [ESM Module FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).\n\u003e * Requires an [ES2020](https://caniuse.com/?search=es2020) or newer runtime\n\u003e * Built-in Typescript types (`@types/mime` no longer needed)\n\n## Installation\n\n```bash\nnpm install mime\n```\n\n## Quick Start\n\nFor the full version (800+ MIME types, 1,000+ extensions):\n\n```javascript\nimport mime from 'mime';\n\nmime.getType('txt');                    // ⇨ 'text/plain'\nmime.getExtension('text/plain');        // ⇨ 'txt'\n```\n\n### Lite Version [![mime/lite's badge](https://deno.bundlejs.com/?q=mime/lite\u0026badge)](https://bundlejs.com/?q=mime/lite)\n\n`mime/lite` is a drop-in `mime` replacement, stripped of unofficial (\"`prs.*`\", \"`x-*`\", \"`vnd.*`\") types:\n\n```javascript\nimport mime from 'mime/lite';\n```\n\n## API\n\n### `mime.getType(pathOrExtension)`\n\nGet mime type for the given file path or extension. E.g.\n\n```javascript\nmime.getType('js');             // ⇨ 'text/javascript'\nmime.getType('json');           // ⇨ 'application/json'\n\nmime.getType('txt');            // ⇨ 'text/plain'\nmime.getType('dir/text.txt');   // ⇨ 'text/plain'\nmime.getType('dir\\\\text.txt');  // ⇨ 'text/plain'\nmime.getType('.text.txt');      // ⇨ 'text/plain'\nmime.getType('.txt');           // ⇨ 'text/plain'\n```\n\n`null` is returned in cases where an extension is not detected or recognized\n\n```javascript\nmime.getType('foo/txt');        // ⇨ null\nmime.getType('bogus_type');     // ⇨ null\n```\n\n### `mime.getExtension(type)`\n\nGet file extension for the given mime type. Charset options (often included in Content-Type headers) are ignored.\n\n```javascript\nmime.getExtension('text/plain');               // ⇨ 'txt'\nmime.getExtension('application/json');         // ⇨ 'json'\nmime.getExtension('text/html; charset=utf8');  // ⇨ 'html'\n```\n\n### `mime.getAllExtensions(type)`\n\n\u003e [!Note]\n\u003e New in `mime@4`\n\nGet all file extensions for the given mime type.\n\n```javascript --run default\nmime.getAllExtensions('image/jpeg'); // ⇨ Set(3) { 'jpeg', 'jpg', 'jpe' }\n```\n\n## Custom `Mime` instances\n\nThe default `mime` objects are immutable.  Custom, mutable versions can be created as follows...\n### new Mime(type map [, type map, ...])\n\nCreate a new, custom mime instance.  For example, to create a mutable version of the default `mime` instance:\n\n```javascript\nimport { Mime } from 'mime/lite';\n\nimport standardTypes from 'mime/types/standard.js';\nimport otherTypes from 'mime/types/other.js';\n\nconst mime = new Mime(standardTypes, otherTypes);\n```\n\nEach argument is passed to the `define()` method, below. For example `new Mime(standardTypes, otherTypes)` is synonomous with `new Mime().define(standardTypes).define(otherTypes)`\n\n### `mime.define(type map [, force = false])`\n\n\u003e [!Note]\n\u003e Only available on custom `Mime` instances\n\nDefine MIME type -\u003e extensions.\n\nAttempting to map a type to an already-defined extension will `throw` unless the `force` argument is set to `true`.\n\n```javascript\nmime.define({'text/x-abc': ['abc', 'abcd']});\n\nmime.getType('abcd');            // ⇨ 'text/x-abc'\nmime.getExtension('text/x-abc')  // ⇨ 'abc'\n```\n\n## Command Line\n\n### Extension -\u003e type\n\n```bash\n$ mime scripts/jquery.js\ntext/javascript\n```\n\n### Type -\u003e extension\n\n```bash\n$ mime -r image/jpeg\njpeg\n```\n","funding_links":["https://github.com/sponsors/broofa"],"categories":["模块","文件","JavaScript","file format (文件格式)","Modules","Packages"],"sub_categories":["其他","Other","Network"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroofa%2Fnode-mime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbroofa%2Fnode-mime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbroofa%2Fnode-mime/lists"}