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

Function getCompressionFormatFromHeader

src/utils/compression.ts:106–118  ·  view source on GitHub ↗
(
  header: Buffer,
)

Source from the content-addressed store, hash-verified

104}
105
106export const getCompressionFormatFromHeader = (
107 header: Buffer,
108): CompressionFormat | undefined => {
109 if (header.length >= GZIP_MAGIC.length && header.subarray(0, GZIP_MAGIC.length).equals(GZIP_MAGIC)) {
110 return CompressionFormat.GZIP
111 }
112
113 if (header.length >= XZ_MAGIC.length && header.subarray(0, XZ_MAGIC.length).equals(XZ_MAGIC)) {
114 return CompressionFormat.XZ
115 }
116
117 return undefined
118}
119
120const readFileHeader = async (filePath: string, bytes = XZ_MAGIC.length): Promise<Buffer> => {
121 const fileHandle = await open(filePath, 'r')

Callers 2

detectCompressionFormatFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected