We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e6934f7 commit 033354dCopy full SHA for 033354d
1 file changed
src/sizeUtils.js
@@ -0,0 +1,8 @@
1
+const zlib = require('zlib');
2
+
3
+export function getCompressedSize(compressionAlgorithm, input) {
4
+ if (compressionAlgorithm === 'gzip') return zlib.gzipSync(input, {level: 9}).length;
5
+ if (compressionAlgorithm === 'brotli') return zlib.brotliCompressSync(input).length;
6
7
+ throw new Error(`Unsupported compression algorithm: ${compressionAlgorithm}.`);
8
+}
0 commit comments