( filePath: string, )
| 131 | } |
| 132 | |
| 133 | export const detectCompressionFormat = async ( |
| 134 | filePath: string, |
| 135 | ): Promise<CompressionFormat | undefined> => { |
| 136 | const extensionFormat = getCompressionFormatFromExtension(filePath) |
| 137 | const header = await readFileHeader(filePath) |
| 138 | const headerFormat = getCompressionFormatFromHeader(header) |
| 139 | |
| 140 | if (extensionFormat && headerFormat && extensionFormat !== headerFormat) { |
| 141 | throw new Error( |
| 142 | `Compression mismatch for ${filePath}: extension suggests ${extensionFormat} but header is ${headerFormat}.`, |
| 143 | ) |
| 144 | } |
| 145 | |
| 146 | return headerFormat ?? extensionFormat |
| 147 | } |
| 148 | |
| 149 | export const createCompressionStream = ( |
| 150 | format?: CompressionFormat, |
no test coverage detected