(filePath: string)
| 219 | |
| 220 | /** Helper just to get and format a file's size for logging. */ |
| 221 | export async function fileSize(filePath: string) { |
| 222 | const text = await readFile(filePath); |
| 223 | const { default: compress } = await import('brotli/compress.js'); |
| 224 | |
| 225 | const data = compress(text, { |
| 226 | mode: 1, |
| 227 | quality: 11, |
| 228 | }); |
| 229 | return { |
| 230 | original: formatFileSize(text.length), |
| 231 | brotli: formatFileSize(data.byteLength), |
| 232 | }; |
| 233 | } |
| 234 | |
| 235 | function formatFileSize(bytes: number) { |
| 236 | if (bytes === 0) return '0b'; |
no test coverage detected
searching dependent graphs…