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

Method advance

packages/effect/src/encoding/Zip.ts:1296–1323  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1294 }
1295
1296 private advance(): Header | undefined | typeof NeedInput {
1297 while (this.current !== undefined) {
1298 if (this.readCurrent() === NeedInput) return NeedInput
1299 }
1300 if (this.finished) return this.finish()
1301 const queue = this.queue
1302 if (queue.length < 4) return this.needInput()
1303 const at = queue.consumed
1304 const head = queue.peek(Math.min(queue.length, 30))
1305 const view = new DataView(head.buffer)
1306 const signature = view.getUint32(0, true)
1307 if (signature === CENTRAL || signature === END || signature === END64) return this.finish()
1308 if (signature !== LOCAL) {
1309 throw invalidHeader(`unexpected signature 0x${signature.toString(16).padStart(8, "0")} at byte ${at}`)
1310 }
1311 if (head.length < 30) return this.needInput()
1312 const length = 30 + view.getUint16(26, true) + view.getUint16(28, true)
1313 if (queue.length < length) return this.needInput()
1314 try {
1315 this.current = this.parseLocal(queue.take(length))
1316 } catch (error) {
1317 if (isZipError(error)) {
1318 throw new ZipError({ kind: error.kind, message: `${error.message} (header at byte ${at})` })
1319 }
1320 throw error
1321 }
1322 return this.current.header
1323 }
1324
1325 // Returns the buffered body bytes of the entry from generation `id`, or
1326 // `undefined` once the whole body has been read and checked

Callers 1

nextMethod · 0.95

Calls 9

readCurrentMethod · 0.95
finishMethod · 0.95
needInputMethod · 0.95
parseLocalMethod · 0.95
isZipErrorFunction · 0.85
invalidHeaderFunction · 0.70
peekMethod · 0.65
toStringMethod · 0.65
takeMethod · 0.65

Tested by

no test coverage detected