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

Function write

packages/effect/src/unstable/socket/Socket.ts:738–753  ·  view source on GitHub ↗
(chunk: Uint8Array | string | CloseEvent)

Source from the content-addressed store, hash-verified

736 )
737
738 const write = (chunk: Uint8Array | string | CloseEvent) =>
739 latch.whenOpen(
740 Effect.suspend(() => {
741 try {
742 const ws = currentWS!
743 if (isCloseEvent(chunk)) {
744 ws.close(chunk.code, chunk.reason)
745 } else {
746 ws.send(chunk as string | Uint8Array<ArrayBuffer>)
747 }
748 return Effect.void
749 } catch (cause) {
750 return Effect.fail(new SocketError({ reason: new SocketWriteError({ cause }) }))
751 }
752 })
753 )
754 const writer = Effect.succeed(write)
755
756 return Effect.succeed(make({

Callers 1

toChannelMapFunction · 0.70

Calls 7

isCloseEventFunction · 0.85
getWriterFunction · 0.85
whenOpenMethod · 0.80
sendMethod · 0.80
closeMethod · 0.65
writeMethod · 0.65
failMethod · 0.45

Tested by

no test coverage detected