aboutsummaryrefslogtreecommitdiff
path: root/ts/njs_modules/zlib.d.ts
blob: c44c5f2d53c3700fc34901f227b83ce153973426 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/// <reference path="../njs_core.d.ts" />

declare module "zlib" {
    interface NjsZlibOptions {
        /**
         * the buffer size for feeding data to and pulling data
         * from the zlib routines, defaults to 1024.
         */
        chunkSize?: number;

        /**
         * The dictionary buffer.
         */
        dictionary?: NjsStringOrBuffer;

        /**
         * Compression level, from zlib.constants.Z_NO_COMPRESSION to
         * zlib.constants.Z_BEST_COMPRESSION. Defaults to
         * zlib.constants.Z_DEFAULT_COMPRESSION.
         */
        level?: number;

        /**
         * Specifies how much memory should be allocated for the internal compression state.
         * 1 uses minimum memory but is slow and reduces compression ratio;
         * 9 uses maximum memory for optimal speed.
         * The default value is 8.
         */
        memLevel?: number;

        /**
         * The compression strategy, defaults to zlib.constants.Z_DEFAULT_STRATEGY.
         */
        strategy?: number;

        /**
         * The log2 of window size.
         * -15 to -9 for raw data, from 9 to 15 for an ordinary stream.
         */
        windowBits?: number;
    }

    type NjsZlibConstants = {
        /**
         * No compression.
         */
        Z_NO_COMPRESSION: number;

        /**
         * Fastest, produces the least compression.
         */
        Z_BEST_SPEED: number;

        /**
         * Trade-off between speed and compression.
         */
        Z_DEFAULT_COMPRESSION: number;

        /**
         * Slowest, produces the most compression.
         */
        Z_BEST_COMPRESSION: number;

        /**
         * Filtered strategy: for the data produced by a filter or predictor.
         */
        Z_FILTERED: number;

        /**
         * Huffman-only strategy: only Huffman encoding, no string matching.
         */
        Z_HUFFMAN_ONLY: number;

        /**
         * Run Length Encoding strategy: limit match distances to one,
         * better compression of PNG image data.
         */
        Z_RLE: number;

        /**
         * Fixed table strategy: prevents the use of dynamic Huffman codes,
         * a simpler decoder for special applications.
         */
        Z_FIXED: number;

        /**
         * Default strategy, suitable for general purpose compression.
         */
        Z_DEFAULT_STRATEGY: number;
    };

    interface Zlib {
        /**
         * Compresses data using deflate, and do not append a zlib header.
         *
         * @param data - The data to be compressed.
         */
        deflateRawSync(data: NjsStringOrBuffer, options?:NjsZlibOptions): Buffer;

        /**
         * Compresses data using deflate.
         *
         * @param data - The data to be compressed.
         */
        deflateSync(data: NjsStringOrBuffer, options?:NjsZlibOptions): Buffer;

        /**
         * Decompresses a raw deflate stream.
         *
         * @param data - The data to be decompressed.
         */
        inflateRawSync(data: NjsStringOrBuffer, options?:NjsZlibOptions): Buffer;

        /**
         * Decompresses a deflate stream.
         *
         * @param data - The data to be decompressed.
         */
        inflateSync(data: NjsStringOrBuffer, options?:NjsZlibOptions): Buffer;

        constants: NjsZlibConstants;
    }

    const zlib: Zlib;

    export default zlib;
}