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

Function loopbackDuplex

packages/platform/node-shared/benchmark/Socket.ts:95–106  ·  view source on GitHub ↗
(respond: (chunk: Buffer, push: (data: Uint8Array) => void) => void)

Source from the content-addressed store, hash-verified

93// with no kernel in the path. The read side is unbounded, so this measures the
94// Socket layer rather than transport backpressure.
95const loopbackDuplex = (respond: (chunk: Buffer, push: (data: Uint8Array) => void) => void): Duplex => {
96 const duplex: Duplex = new Duplex({
97 read() {},
98 write(chunk: Buffer, _encoding, callback) {
99 respond(chunk, (data) => {
100 duplex.push(data)
101 })
102 callback()
103 }
104 })
105 return duplex
106}
107
108const duplexEcho = (): Duplex => loopbackDuplex((chunk, push) => push(chunk))
109

Callers 2

duplexEchoFunction · 0.85
duplexStreamFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected