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

Function takeOver

packages/platform/node/src/NodeHttpClient.ts:584–595  ·  view source on GitHub ↗
(conn: Duplex, head: Uint8Array | undefined, signal: AbortSignal)

Source from the content-addressed store, hash-verified

582const loadUpgrade = Effect.promise(() => import("./internal/upgrade.ts"))
583
584const takeOver = (conn: Duplex, head: Uint8Array | undefined, signal: AbortSignal): Duplex => {
585 if (head !== undefined && head.length > 0) conn.unshift(head)
586 conn.on("error", constVoid)
587 if (signal.aborted) {
588 conn.destroy()
589 } else {
590 const onAbort = () => conn.destroy()
591 signal.addEventListener("abort", onAbort, { once: true })
592 conn.once("close", () => signal.removeEventListener("abort", onAbort))
593 }
594 return conn
595}
596
597const upgradeSocket = (
598 response: HttpClientResponse,

Callers 2

onRequestUpgradeFunction · 0.70
onUpgradeFunction · 0.70

Calls 5

onceMethod · 0.80
onMethod · 0.65
addEventListenerMethod · 0.65
removeEventListenerMethod · 0.65
destroyMethod · 0.45

Tested by

no test coverage detected