Skip to content

Commit de5dbea

Browse files
committed
Use promisify for gzip
1 parent 84de8ad commit de5dbea

File tree

1 file changed

+4
-35
lines changed
  • extensions/ql-vscode/src/common

1 file changed

+4
-35
lines changed
Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,12 @@
1-
import { gzip, gunzip, InputType as ZlibInputType, ZlibOptions } from "zlib";
1+
import { promisify } from "util";
2+
import { gzip, gunzip } from "zlib";
23

34
/**
45
* Promisified version of zlib.gzip
5-
* @param buffer Buffer to compress
6-
* @param options zlib options
76
*/
8-
export function gzipEncode(
9-
buffer: ZlibInputType,
10-
options: ZlibOptions = {},
11-
): Promise<Buffer> {
12-
return new Promise((resolve, reject) => {
13-
gzip(buffer, options, (error, result) => {
14-
if (error) {
15-
reject(error);
16-
return;
17-
}
18-
19-
resolve(result);
20-
});
21-
});
22-
}
7+
export const gzipEncode = promisify(gzip);
238

249
/**
2510
* Promisified version of zlib.gunzip
26-
* @param buffer Buffer to decompress
27-
* @param options zlib options
2811
*/
29-
export function gzipDecode(
30-
buffer: ZlibInputType,
31-
options: ZlibOptions = {},
32-
): Promise<Buffer> {
33-
return new Promise((resolve, reject) => {
34-
gunzip(buffer, options, (error, result) => {
35-
if (error) {
36-
reject(error);
37-
return;
38-
}
39-
40-
resolve(result);
41-
});
42-
});
43-
}
12+
export const gzipDecode = promisify(gunzip);

0 commit comments

Comments
 (0)