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

Function rawDuplexClient

packages/platform/node-shared/benchmark/Socket.ts:185–197  ·  view source on GitHub ↗
(conn: Duplex)

Source from the content-addressed store, hash-verified

183}
184
185const rawDuplexClient = (conn: Duplex): RawClient => {
186 const counter = makeReadCounter()
187 conn.on("data", (chunk: Buffer) => counter.push(chunk.length))
188 return {
189 write(frames) {
190 let flushed = true
191 for (const frame of frames) flushed = conn.write(frame)
192 return flushed ? Promise.resolve() : once(conn, "drain").then(() => {})
193 },
194 read: counter.read,
195 close: () => conn.destroy()
196 }
197}
198
199interface SocketClient {
200 readonly write: (frames: NonEmptyReadonlyArray<Uint8Array>) => Effect.Effect<void>

Callers 1

Socket.tsFile · 0.85

Calls 4

makeReadCounterFunction · 0.85
onMethod · 0.65
pushMethod · 0.65
destroyMethod · 0.45

Tested by

no test coverage detected