Skip to content

Commit 3a81815

Browse files
authored
🤖 Merge PR DefinitelyTyped#74603 [@types/brotli]: update types by @arturovt
1 parent 209e911 commit 3a81815

4 files changed

Lines changed: 31 additions & 10 deletions

File tree

types/brotli/brotli-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import * as brotli from "brotli";
22
import compress = require("brotli/compress");
33
import decompress = require("brotli/decompress");
44

5-
// $ExpectType Uint8Array || Uint8Array<ArrayBufferLike>
5+
// $ExpectType Uint8Array | null || Uint8Array<ArrayBufferLike> | null
66
brotli.compress(Buffer.from("hello"));
77
// $ExpectType Uint8Array || Uint8Array<ArrayBufferLike>
88
brotli.decompress(Buffer.from("hello"));
99

10-
// $ExpectType Uint8Array || Uint8Array<ArrayBufferLike>
10+
// $ExpectType Uint8Array | null || Uint8Array<ArrayBufferLike> | null
1111
compress(Buffer.from("hello"));
1212
compress(Buffer.from("hello"), {});
1313
// $ExpectType Uint8Array || Uint8Array<ArrayBufferLike>

types/brotli/compress.d.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
interface CompressOptions {
22
/**
3-
* The Brotli compression mode. Possible modes are:
4-
* 0 - generic (default)
5-
* 1 - text (for UTF-8 format text input)
6-
* 2 - font (WOFF2)
3+
* The Brotli compression mode:
4+
* - `0` - generic (default)
5+
* - `1` - text (for UTF-8 format text input)
6+
* - `2` - font (WOFF2)
77
*/
88
mode?: 0 | 1 | 2 | undefined;
99
/**
10-
* The Brotli quality level, possible levels are 0-11. The default level is 11.
10+
* The Brotli quality level, ranging from 0 (fastest) to 11 (best compression).
11+
* @default 11
1112
*/
1213
quality?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | undefined;
1314
/**
14-
* The LZ77 window size, default is 22.
15+
* The LZ77 window size. Valid range is 10-24.
16+
* @default 22
1517
*/
1618
lgwin?: number | undefined;
19+
/**
20+
* An optional pre-shared dictionary to improve compression ratio.
21+
* Both the compressor and decompressor must use the same dictionary.
22+
*/
23+
dictionary?: string | undefined;
1724
}
1825

19-
declare function compress(buffer: Buffer, options?: CompressOptions): Uint8Array;
26+
/**
27+
* Compresses the given buffer using the Brotli algorithm.
28+
* Returns `null` on error.
29+
*
30+
* @param buffer - The input data to compress.
31+
* @param options - Optional compression settings.
32+
*/
33+
declare function compress(buffer: Buffer, options?: CompressOptions): Uint8Array | null;
2034

2135
export = compress;

types/brotli/decompress.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* Decompresses a Brotli-compressed buffer.
3+
*
4+
* @param buffer - A Brotli-compressed buffer.
5+
* @param outputSize - Optional expected output size. If not provided, it will
6+
* be determined automatically by reading the meta-block header.
7+
*/
18
declare function decompress(buffer: Buffer, outputSize?: number): Uint8Array;
29

310
export = decompress;

types/brotli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"owners": [
1515
{
16-
"name": "Artur Androsovych",
16+
"name": "arturovt",
1717
"githubUsername": "arturovt"
1818
}
1919
]

0 commit comments

Comments
 (0)