diff --git a/README.md b/README.md index 08ddad4..4f49e01 100644 --- a/README.md +++ b/README.md @@ -3,25 +3,23 @@ --> # Mime -A comprehensive, compact MIME type module. - -[![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) -[![NPM version](https://img.shields.io/npm/v/mime)](https://www.npmjs.com/package/mime) [![NPM downloads](https://img.shields.io/npm/dm/mime)](https://www.npmjs.com/package/mime) +[![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) + +An API for MIME type information. + +- All `mime-db` types +- Compact and dependency-free [![mime's badge](https://deno.bundlejs.com/?q=mime&badge)](https://bundlejs.com/?q=mime) +- Full TS support + > **Important** -> `mime@4` is currently in **beta**. To install: -> ```bash -> npm install mime@beta -> ``` -> -> Starting with `mime@4`: -> * ESM module support is required. See the [ESM Module FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you need CommonJS support (e.g. `require('mime')`), use `mime@3`. +> `mime@4` is currently in **beta**. Changes include: +> * ESM module support is required. See the [ESM Module FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). > * [ES2020](https://caniuse.com/?search=es2020) support is required -> * Typescript types are built-in. (`@types/mime` is no longer needed) +> * Typescript types are built-in > -> See [CHANGELOG.md](https://github.com/broofa/mime/blob/main/CHANGELOG.md) for further details - +> To install: ` npm install mime@beta` ## Install ```bash @@ -39,34 +37,14 @@ mime.getType('txt'); // ⇨ 'text/plain' mime.getExtension('text/plain'); // ⇨ 'txt' ``` -See [Mime API](#mime-api) below for API details. +### Lite Version [![mime/lite's badge](https://deno.bundlejs.com/?q=mime/lite&badge)](https://bundlejs.com/?q=mime/lite) -## Lite Version - -The "lite" version of this module omits vendor-specific (`*/vnd.*`) and experimental (`*/x-*`) types. It weighs in at ~2.5KB, compared to 8KB for the full version. To load the lite version: +`mime/lite` is a drop-in `mime` replacement, stripped of unofficial ("`prs.*`", "`x-*`", "`vnd.*`") types: ```javascript import mime from 'mime/lite'; ``` -## Mime .vs. mime-types .vs. mime-db modules - -For those of you wondering about the difference between these [popular] NPM modules, -here's a brief rundown ... - -[`mime-db`](https://github.com/jshttp/mime-db) is "the source of -truth" for MIME type information. It is a dataset (JSON file), not an API, with mime type definitions pulled from a variety of authoritative sources. - -[`mime-types`](https://github.com/jshttp/mime-types) is a thin -wrapper around mime-db that provides an API that is mostly-compatible with `mime @ < v1.3.6`. - -`mime` (this project) is like `mime-types`, but with the following enhancements: - -- Resolves type conflicts (See [mime-score](https://github.com/broofa/mime-score) for details) -- Smaller (`mime` is 2-8KB, `mime-types` is 18KB) -- Zero dependencies -- Built-in TS support - ## API ### `mime.getType(pathOrExtension)` @@ -159,4 +137,4 @@ mime.getExtension('text/x-abc') // ⇨ 'abc' jpeg ---- -Markdown generated from [src/README_js.md](src/README_js.md) by [![RunMD Logo](https://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd) +Markdown generated from [src/README_js.md](src/README_js.md) by [](https://github.com/broofa/runmd) diff --git a/docs/README_js.md b/docs/README_js.md index 36cfe3f..d80e02c 100644 --- a/docs/README_js.md +++ b/docs/README_js.md @@ -4,25 +4,23 @@ runmd.onRequire = (path) => path.replace(/^mime/, '../dist/src/index.js'); # Mime -A comprehensive, compact MIME type module. - -[![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) -[![NPM version](https://img.shields.io/npm/v/mime)](https://www.npmjs.com/package/mime) [![NPM downloads](https://img.shields.io/npm/dm/mime)](https://www.npmjs.com/package/mime) +[![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) + +An API for MIME type information. + +- All `mime-db` types +- Compact and dependency-free [![mime's badge](https://deno.bundlejs.com/?q=mime&badge)](https://bundlejs.com/?q=mime) +- Full TS support + > **Important** -> `mime@4` is currently in **beta**. To install: -> ```bash -> npm install mime@beta -> ``` -> -> Starting with `mime@4`: -> * ESM module support is required. See the [ESM Module FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you need CommonJS support (e.g. `require('mime')`), use `mime@3`. +> `mime@4` is currently in **beta**. Changes include: +> * ESM module support is required. See the [ESM Module FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). > * [ES2020](https://caniuse.com/?search=es2020) support is required -> * Typescript types are built-in. (`@types/mime` is no longer needed) +> * Typescript types are built-in > -> See [CHANGELOG.md](https://github.com/broofa/mime/blob/main/CHANGELOG.md) for further details - +> To install: ` npm install mime@beta` ## Install ```bash @@ -40,34 +38,14 @@ mime.getType('txt'); // RESULT mime.getExtension('text/plain'); // RESULT ``` -See [Mime API](#mime-api) below for API details. +### Lite Version [![mime/lite's badge](https://deno.bundlejs.com/?q=mime/lite&badge)](https://bundlejs.com/?q=mime/lite) -### Lite Version - -The "lite" version of this module omits vendor-specific (`*/vnd.*`) and experimental (`*/x-*`) types. It weighs in at ~2.5KB, compared to 8KB for the full version. To load the lite version: +`mime/lite` is a drop-in `mime` replacement, stripped of unofficial ("`prs.*`", "`x-*`", "`vnd.*`") types: ```javascript import mime from 'mime/lite'; ``` -## Mime .vs. mime-types .vs. mime-db modules - -For those of you wondering about the difference between these [popular] NPM modules, -here's a brief rundown ... - -[`mime-db`](https://github.com/jshttp/mime-db) is "the source of -truth" for MIME type information. It is a dataset (JSON file), not an API, with mime type definitions pulled from a variety of authoritative sources. - -[`mime-types`](https://github.com/jshttp/mime-types) is a thin -wrapper around mime-db that provides an API that is mostly-compatible with `mime @ < v1.3.6`. - -`mime` (this project) is like `mime-types`, but with the following enhancements: - -- Resolves type conflicts (See [mime-score](https://github.com/broofa/mime-score) for details) -- Smaller (`mime` is 2-8KB, `mime-types` is 18KB) -- Zero dependencies -- Built-in TS support - ## API ### `mime.getType(pathOrExtension)`