Skip to content

Commit 2b2faaf

Browse files
committed
chore: update readme
1 parent 0746da3 commit 2b2faaf

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

README.md

+25-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Drop-in replacement of the built-in [Compress Middleware](https://hono.dev/docs/
88

99
- all available compression formats (`zstd`, `brotli`, `gzip`, `deflate`)
1010
- ultra-fast and 100% type-safe
11-
- auto best format selection
11+
- best format auto-selection
1212
- streaming response support
1313
- configurable compression level and zlib options
1414
- double-compressed content protection
@@ -101,16 +101,18 @@ Can be one of the following:
101101
- `gzip`
102102
- `deflate`
103103

104-
If not defined, all the supported encodings are allowed based on the request header `Accept-Encoding` and will be used in their order of declaration.
104+
If not defined, all the formats defined in the option `encodings` are allowed.
105105

106-
This option is provided mainly to maintain compatibility with `hono/compress`, it's recommended to set the compression formats using `encodings` instead.
106+
This option is provided primarily to maintain compatibility with `hono/compress`; it is recommended to use the option `encodings` to set the wanted compression formats.
107107

108108
#### encodings
109109

110110
Defaults to `['zstd', 'br', 'gzip', 'deflate']`.
111111

112112
The compression formats allowed to be used to compress the response content.
113113

114+
The first format matching the request header `Accept-Encoding` is chosen to be used to compress the response content.
115+
114116
#### threshold
115117

116118
Defaults to `1024`.
@@ -131,7 +133,7 @@ Defaults to `4`.
131133

132134
Brotli algorithm compression level.
133135

134-
Refer to the Brotli [website](https://www.brotli.org/) for more details.
136+
Refer to the Brotli [specification](https://www.ietf.org/rfc/rfc7932.txt) for more details.
135137

136138
#### zlibLevel
137139

@@ -153,7 +155,25 @@ Refer to the node zlib [documentation](https://nodejs.org/api/zlib.html) for mor
153155

154156
Defaults to `undefined`.
155157

156-
A function callback to state if response content should be compressed or not.
158+
An optional function callback to state if the response content should be compressed or not.
159+
160+
**Parameters**
161+
162+
- [Hono Context](https://hono.dev/docs/api/context)
163+
164+
**Return value**
165+
166+
Boolean
167+
168+
By default, content compression is disabled on Cloudflare Workers and Deno Deploy, a custom filter can be used to bypass this behavior and force the response to be always compressed:
169+
170+
```typescript
171+
import type { Context } from 'hono'
172+
173+
compress({
174+
filter: (c: Context) => true,
175+
})
176+
```
157177

158178
## About
159179

0 commit comments

Comments
 (0)