MCPcopy Index your code
hub / github.com/cameri/nostream / detectCompressionFormat

Function detectCompressionFormat

src/utils/compression.ts:133–147  ·  view source on GitHub ↗
(
  filePath: string,
)

Source from the content-addressed store, hash-verified

131}
132
133export 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
149export const createCompressionStream = (
150 format?: CompressionFormat,

Callers 2

ensureValidInputFileFunction · 0.90

Calls 3

readFileHeaderFunction · 0.85

Tested by

no test coverage detected