Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
broofa committed Nov 29, 2023
1 parent 0202521 commit 31e3258
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
34 changes: 19 additions & 15 deletions docs/README_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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.
Expand All @@ -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
```
2 changes: 1 addition & 1 deletion src/Mime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 31e3258

Please sign in to comment.