MCPcopy Create free account
hub / github.com/Effect-TS/effect / begin

Method begin

packages/effect/src/encoding/Zip.ts:1136–1159  ·  view source on GitHub ↗
(header: Header)

Source from the content-addressed store, hash-verified

1134
1135 // Starts an entry whose sizes and CRC-32 follow its data
1136 begin(header: Header): void {
1137 const directory = header.type === "Directory"
1138 const stored = directory || header.method === "Store"
1139 const size = directory ? 0 : header.size
1140 if (stored && size === undefined) {
1141 throw invalidHeader(`stored file ${JSON.stringify(header.path)} is streamed without a size`)
1142 }
1143 // An empty stored entry needs no descriptor: readers would take its zero
1144 // sizes for missing ones
1145 const descriptor = !(stored && size === 0)
1146 const record = this.record(header, descriptor ? FLAG_DESCRIPTOR : 0)
1147 // Streaming readers find the end of stored data from its size
1148 if (stored) {
1149 record.size = size!
1150 record.compressedSize = size!
1151 }
1152 // The local header fixes the width of the sizes after the data, so declare
1153 // ZIP64 whenever they could reach 4 GiB
1154 record.zip64 = size === undefined || size >= (stored ? MAX32 : MAX32 - DEFLATE_HEADROOM)
1155 this.push(localHeader(record))
1156 record.size = 0
1157 record.compressedSize = 0
1158 this.current = { header, record, descriptor }
1159 }
1160
1161 // Accounts for uncompressed body bytes
1162 update(chunks: ReadonlyArray<Uint8Array>): void {

Callers 3

encodeFunction · 0.95
runCompactionFunction · 0.45

Calls 4

recordMethod · 0.95
pushMethod · 0.95
invalidHeaderFunction · 0.70
localHeaderFunction · 0.70

Tested by

no test coverage detected