(chunk: Uint8Array | string | CloseEvent)
| 1197 | : connect |
| 1198 | |
| 1199 | const write = (chunk: Uint8Array | string | CloseEvent): Effect.Effect<void, SocketError> => |
| 1200 | Effect.suspend(() => { |
| 1201 | if (terminalError !== undefined) return Effect.fail(terminalError) |
| 1202 | const ws = currentWS |
| 1203 | if (ws === undefined) return latch.whenOpen(write(chunk)) |
| 1204 | try { |
| 1205 | if (isCloseEvent(chunk)) { |
| 1206 | ws.close(chunk.code, chunk.reason) |
| 1207 | } else { |
| 1208 | ws.send(chunk as string | Uint8Array<ArrayBuffer>) |
| 1209 | } |
| 1210 | return Effect.void |
| 1211 | } catch (cause) { |
| 1212 | return Effect.fail(new SocketError({ reason: new SocketWriteError({ cause }) })) |
| 1213 | } |
| 1214 | }) |
| 1215 | const writeAll = ( |
| 1216 | chunks: NonEmptyReadonlyArray<Uint8Array | string> |
| 1217 | ): Effect.Effect<void, SocketError> => |
nothing calls this directly
no test coverage detected