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

Function read

packages/platform/node/src/NodeHttpPlatform.ts:33–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31 let source: Readable | undefined
32 return new Readable({
33 read() {
34 if (source === undefined) {
35 try {
36 source = evaluate()
37 } catch (cause) {
38 this.destroy(cause instanceof Error ? cause : new Error(String(cause)))
39 return
40 }
41 source.on("data", (chunk) => {
42 if (!this.push(chunk)) source!.pause()
43 })
44 source.once("end", () => this.push(null))
45 source.once("error", (cause) => this.destroy(cause))
46 source.once("close", () => {
47 if (!source!.readableEnded) this.destroy(new Error("Response stream closed prematurely"))
48 })
49 }
50 source.resume()
51 },
52 destroy(error, callback) {
53 source?.destroy(error ?? undefined)
54 onDestroy?.()

Callers

nothing calls this directly

Calls 8

onceMethod · 0.80
evaluateFunction · 0.70
onMethod · 0.65
pushMethod · 0.65
pauseMethod · 0.65
resumeMethod · 0.65
StringFunction · 0.50
destroyMethod · 0.45

Tested by

no test coverage detected