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

Function writeAll

packages/effect/src/socket/Socket.ts:1215–1230  ·  view source on GitHub ↗
(
      chunks: NonEmptyReadonlyArray<Uint8Array | string>
    )

Source from the content-addressed store, hash-verified

1213 }
1214 })
1215 const writeAll = (
1216 chunks: NonEmptyReadonlyArray<Uint8Array | string>
1217 ): Effect.Effect<void, SocketError> =>
1218 Effect.suspend(() => {
1219 if (terminalError !== undefined) return Effect.fail(terminalError)
1220 const ws = currentWS
1221 if (ws === undefined) return latch.whenOpen(writeAll(chunks))
1222 try {
1223 for (let i = 0; i < chunks.length; i++) {
1224 ws.send(chunks[i] as string | Uint8Array<ArrayBuffer>)
1225 }
1226 return Effect.void
1227 } catch (cause) {
1228 return Effect.fail(new SocketError({ reason: new SocketWriteError({ cause }) }))
1229 }
1230 })
1231 const writer: Socket["writer"] = Effect.succeed({ write, writeAll })
1232
1233 return Effect.succeed(make({ reader, writer }))

Callers

nothing calls this directly

Calls 6

getWriterFunction · 0.85
whenOpenMethod · 0.80
encodeMethod · 0.80
failMethod · 0.65
sendMethod · 0.65
writeMethod · 0.65

Tested by

no test coverage detected