diff --git a/docs/README_js.md b/docs/README_js.md index d80e02c..937c0e5 100644 --- a/docs/README_js.md +++ b/docs/README_js.md @@ -14,14 +14,14 @@ An API for MIME type information. - Full TS support -> **Important** -> `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 -> -> To install: ` npm install mime@beta` -## Install +> [Note!] +> `mime@4` has now `latest`. If you're upgrading from `mime@3`, note the following: +> * `mime@4` is API-compatible with `mime@3`, with one exception: `mime.define()` cannot be called on the default `mime` object. +> * ESM module support is required. [ESM Module FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). +> * Requires an [ES2020](https://caniuse.com/?search=es2020) or newer runtime +> * Built-in Typescript types (`@types/mime` no longer needed) + +## Installation ```bash npm install mime @@ -82,7 +82,7 @@ mime.getExtension('text/html; charset=utf8'); // RESULT ### `mime.getAllExtensions(type)` -> **Note** +> [!Note] > New in `mime@4` Get all file extensions for the given mime type. @@ -93,7 +93,7 @@ mime.getAllExtensions('text/plain'); // RESULT ## Custom `Mime` instances -The default objects exported by `mime` are immutable by design. Mutable versions can be created as follows... +The default `mime` objects are immutable. Custom, mutable versions can be created as follows... ### new Mime(type map [, type map, ...]) Create a new, custom mime instance. For example, to create a mutable version of the default `mime` instance: @@ -111,7 +111,7 @@ Each argument is passed to the `define()` method, below. For example `new Mime(s ### `mime.define(type map [, force = false])` -> **Note** +> [!Note] > Only available on custom `Mime` instances Define MIME type -> extensions. @@ -129,10 +129,14 @@ mime.getExtension('text/x-abc'); // RESULT ### Extension -> type - $ mime scripts/jquery.js - application/javascript +```bash +$ mime scripts/jquery.js +application/javascript +``` ### Type -> extension - $ npx mime -r image/jpeg - jpeg +```bash +$ mime -r image/jpeg +jpeg +``` \ No newline at end of file diff --git a/src/Mime.ts b/src/Mime.ts index f81268c..a28323b 100644 --- a/src/Mime.ts +++ b/src/Mime.ts @@ -116,7 +116,7 @@ export default class Mime { _freeze() { this.define = () => { - throw new Error('define() not allowed for built-in Mime objects.'); + throw new Error('define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances'); }; Object.freeze(this);