MCPcopy
hub / github.com/Effect-TS/effect / run

Function run

packages/platform/src/Socket.ts:492–500  ·  view source on GitHub ↗
(handler: (_: Uint8Array) => Effect.Effect<_, E, R> | void, opts?: {
      readonly onOpen?: Effect.Effect<void> | undefined
    })

Source from the content-addressed store, hash-verified

490
491 const encoder = new TextEncoder()
492 const run = <_, E, R>(handler: (_: Uint8Array) => Effect.Effect<_, E, R> | void, opts?: {
493 readonly onOpen?: Effect.Effect<void> | undefined
494 }) =>
495 runRaw((data) =>
496 typeof data === "string"
497 ? handler(encoder.encode(data))
498 : data instanceof Uint8Array
499 ? handler(data)
500 : handler(new Uint8Array(data)), opts)
501
502 const write = (chunk: Uint8Array | string | CloseEvent) =>
503 latch.whenOpen(Effect.sync(() => {

Callers 3

onMessageFunction · 0.70
toWebHandlerRuntimeFunction · 0.70
layerFunction · 0.50

Calls 3

encodeMethod · 0.80
runRawFunction · 0.70
handlerFunction · 0.70

Tested by

no test coverage detected