Skip to content

Commit 4dfbb5c

Browse files
committed
Add Brotli size helper
1 parent ec1fa85 commit 4dfbb5c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/sizeUtils.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ const zlib = require('zlib');
33
export function gzipSize(input) {
44
return zlib.gzipSync(input, {level: 9}).length;
55
}
6+
7+
export function brotliSize(input) {
8+
if (typeof zlib.brotliCompressSync !== 'function') {
9+
throw new Error('Brotli compression requires Node.js v10.16.0 or higher.');
10+
}
11+
12+
return zlib.brotliCompressSync(input).length;
13+
}

0 commit comments

Comments
 (0)