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

Function toChannel

packages/effect/src/unstable/socket/Socket.ts:444–455  ·  view source on GitHub ↗
(
  self: Socket
)

Source from the content-addressed store, hash-verified

442 * @since 4.0.0
443 */
444export const toChannel = <IE>(
445 self: Socket
446): Channel.Channel<
447 NonEmptyReadonlyArray<Uint8Array>,
448 SocketError | IE,
449 void,
450 NonEmptyReadonlyArray<Uint8Array | string | CloseEvent>,
451 IE
452> => {
453 const encoder = new TextEncoder()
454 return toChannelMap(self, (data) => typeof data === "string" ? encoder.encode(data) : data)
455}
456
457/**
458 * Converts a `Socket` into a string `Channel`, decoding binary frames with the

Callers 1

toChannelWithFunction · 0.70

Calls 1

toChannelMapFunction · 0.85

Tested by

no test coverage detected