Skip to content

Commit da47bcb

Browse files
committed
docs: add zlib options to readme
closes #28
1 parent 26d96b3 commit da47bcb

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ Returns the compression middleware using the given `options`.
3535
those listed below, [zlib](http://nodejs.org/api/zlib.html) options may be
3636
passed in to the options object.
3737

38+
##### chunkSize
39+
40+
The default value is `zlib.Z_DEFAULT_CHUNK`, or `16384`.
41+
42+
See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
43+
regarding the usage.
44+
3845
##### filter
3946

4047
A function to decide if the response should be considered for compression.
@@ -67,6 +74,41 @@ compression level".
6774
- `8`
6875
- `9` Best compression (also `zlib.Z_BEST_COMPRESSION`).
6976

77+
The default value is `zlib.Z_DEFAULT_COMPRESSION`, or `-1`.
78+
79+
**Note** in the list above, `zlib` is from `zlib = require('zlib')`.
80+
81+
##### memLevel
82+
83+
This specifies how much memory should be allocated for the internal compression
84+
state and is an integer in the range of `1` (minimum level) and `9` (maximum
85+
level).
86+
87+
The default value is `zlib.Z_DEFAULT_MEMLEVEL`, or `8`.
88+
89+
See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
90+
regarding the usage.
91+
92+
##### strategy
93+
94+
This is used to tune the compression algorithm. This value only affects the
95+
compression ratio, not the correctness of the compressed output, even if it
96+
is not set appropriately.
97+
98+
- `zlib.Z_DEFAULT_STRATEGY` Use for normal data.
99+
- `zlib.Z_FILTERED` Use for data produced by a filter (or predictor).
100+
Filtered data consists mostly of small values with a somewhat random
101+
distribution. In this case, the compression algorithm is tuned to
102+
compress them better. The effect is to force more Huffman coding and less
103+
string matching; it is somewhat intermediate between `zlib.Z_DEFAULT_STRATEGY`
104+
and `zlib.Z_HUFFMAN_ONLY`.
105+
- `zlib.Z_FIXED` Use to prevent the use of dynamic Huffman codes, allowing
106+
for a simpler decoder for special applications.
107+
- `zlib.Z_HUFFMAN_ONLY` Use to force Huffman encoding only (no string match).
108+
- `zlib.Z_RLE` Use to limit match distances to one (run-length encoding).
109+
This is designed to be almost as fast as `zlib.Z_HUFFMAN_ONLY`, but give
110+
better compression for PNG image data.
111+
70112
**Note** in the list above, `zlib` is from `zlib = require('zlib')`.
71113

72114
##### threshold
@@ -75,6 +117,13 @@ The byte threshold for the response body size before compression is considered
75117
for the response, defaults to `1kb`. This is a number of bytes, any string
76118
accepted by the [bytes](https://www.npmjs.com/package/bytes) module, or `false`.
77119

120+
##### windowBits
121+
122+
The default value is `zlib.Z_DEFAULT_WINDOWBITS`, or `15`.
123+
124+
See [Node.js documentation](http://nodejs.org/api/zlib.html#zlib_memory_usage_tuning)
125+
regarding the usage.
126+
78127
#### .filter
79128

80129
The default `filter` function. This is used to construct a custom filter

0 commit comments

Comments
 (0)