Skip to content

Commit

Permalink
fix: Override Brotli compress default options (#26648)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov authored Jan 16, 2024
1 parent 79f6d8a commit 5506224
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/util/compress.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { promisify } from 'node:util';
import zlib from 'node:zlib';
import zlib, { constants } from 'node:zlib';

const brotliCompress = promisify(zlib.brotliCompress);
const brotliDecompress = promisify(zlib.brotliDecompress);

export async function compress(input: string): Promise<string> {
const buf = await brotliCompress(input);
const buf = await brotliCompress(input, {
params: {
[constants.BROTLI_PARAM_MODE]: constants.BROTLI_MODE_TEXT,
[constants.BROTLI_PARAM_QUALITY]: 8,
},
});
return buf.toString('base64');
}

Expand Down

0 comments on commit 5506224

Please sign in to comment.