mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
16 lines
506 B
TypeScript
16 lines
506 B
TypeScript
import { promisify } from 'util';
|
|
import zlib from 'zlib';
|
|
|
|
const brotliCompress = promisify(zlib.brotliCompress);
|
|
const brotliDecompress = promisify(zlib.brotliDecompress);
|
|
|
|
export async function compress(input: string): Promise<string> {
|
|
const buf = await brotliCompress(input);
|
|
return buf.toString('base64');
|
|
}
|
|
|
|
export async function decompress(input: string): Promise<string> {
|
|
const buf = Buffer.from(input, 'base64');
|
|
const str = await brotliDecompress(buf);
|
|
return str.toString('utf8');
|
|
}
|