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

Method read

packages/effect/src/encoding/Tar.ts:1260–1279  ·  view source on GitHub ↗
(id: number)

Source from the content-addressed store, hash-verified

1258 // Returns the buffered body bytes of the entry from generation `id`, or
1259 // `undefined` once the whole body has been read
1260 read(id: number): Arr.NonEmptyArray<Uint8Array> | undefined | typeof NeedInput {
1261 if (id !== this.generation) {
1262 throw new TarError({
1263 kind: "BodyConsumed",
1264 message: this.closed ?
1265 "tar entry body read after the archive stream ended" :
1266 "tar entry body read after moving to the next entry"
1267 })
1268 }
1269 if (this.remaining === 0) return undefined
1270 if (this.queue.length === 0) return this.needInput()
1271 const chunks = Arr.of(this.queue.takeSome(this.remaining))
1272 this.remaining -= chunks[0].length
1273 while (this.remaining > 0 && this.queue.length > 0) {
1274 const chunk = this.queue.takeSome(this.remaining)
1275 this.remaining -= chunk.length
1276 chunks.push(chunk)
1277 }
1278 return chunks
1279 }
1280
1281 private needInput(): typeof NeedInput {
1282 if (this.ended) throw truncated(this.queue.consumed + this.queue.length)

Callers

nothing calls this directly

Calls 4

needInputMethod · 0.95
ofMethod · 0.65
pushMethod · 0.65
takeSomeMethod · 0.45

Tested by

no test coverage detected