Skip to content

Commit

Permalink
Add Brotli size helper
Browse files Browse the repository at this point in the history
  • Loading branch information
dcsaszar committed Apr 13, 2021
1 parent ec1fa85 commit 4dfbb5c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/sizeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ const zlib = require('zlib');
export function gzipSize(input) {
return zlib.gzipSync(input, {level: 9}).length;
}

export function brotliSize(input) {
if (typeof zlib.brotliCompressSync !== 'function') {
throw new Error('Brotli compression requires Node.js v10.16.0 or higher.');
}

return zlib.brotliCompressSync(input).length;
}

0 comments on commit 4dfbb5c

Please sign in to comment.