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

Function write

packages/platform/deno/src/DenoSocket.ts:147–162  ·  view source on GitHub ↗
(chunk: Uint8Array | string | Socket.CloseEvent)

Source from the content-addressed store, hash-verified

145 )
146
147 const write = (chunk: Uint8Array | string | Socket.CloseEvent) =>
148 latch.whenOpen(Effect.suspend(() => {
149 const { conn, writer } = current!
150 if (Socket.isCloseEvent(chunk)) {
151 tearingDown = true
152 return close(conn)
153 }
154 const bytes = typeof chunk === "string" ? encoder.encode(chunk) : chunk
155 return Effect.tryPromise({
156 try: () => writer.ready.then(() => writer.write(bytes)),
157 catch: (cause) =>
158 new Socket.SocketError({
159 reason: new Socket.SocketWriteError({ cause })
160 })
161 })
162 }))
163
164 const writer = Effect.acquireRelease(
165 Effect.sync(() => {

Callers 1

sendFunction · 0.50

Calls 3

whenOpenMethod · 0.80
closeFunction · 0.70
writeMethod · 0.65

Tested by

no test coverage detected