MCPcopy
hub / github.com/Effect-TS/effect / write

Function write

packages/platform-node-shared/src/NodeSocket.ts:166–180  ·  view source on GitHub ↗
(chunk: Uint8Array | string | Socket.CloseEvent)

Source from the content-addressed store, hash-verified

164 )
165
166 const write = (chunk: Uint8Array | string | Socket.CloseEvent) =>
167 latch.whenOpen(Effect.async<void, Socket.SocketError>((resume) => {
168 const conn = currentSocket!
169 if (Socket.isCloseEvent(chunk)) {
170 conn.destroy(chunk.code > 1000 ? new Error(`closed with code ${chunk.code}`) : undefined)
171 return resume(Effect.void)
172 }
173 currentSocket!.write(chunk, (cause) => {
174 resume(
175 cause
176 ? Effect.fail(new Socket.SocketGenericError({ reason: "Write", cause }))
177 : Effect.void
178 )
179 })
180 }))
181
182 const writer = Effect.acquireRelease(
183 Effect.succeed(write),

Callers

nothing calls this directly

Calls 4

destroyMethod · 0.80
writeMethod · 0.65
failMethod · 0.65
resumeFunction · 0.50

Tested by

no test coverage detected