NodeSocket unstable
Node.js socket constructors and layers for Effect sockets.
This module re-exports the shared Node socket support for TCP connections,
Unix domain socket connections, and Node Duplex streams. It also provides
WebSocket constructor layers: one that uses globalThis.WebSocket when
present and falls back to ws, one that always uses ws, and one that
creates a Socket.Socket layer for a WebSocket URL.
Layers
layerWebSocket
unstableCreates a Socket.Socket layer for a WebSocket URL using the Node WebSocket
constructor layer, honoring protocol, handshake-header, open-timeout, and
high-water-mark options.
Signature
declare const layerWebSocket: (url: string | Effect.Effect<string>, options?: { readonly headers?: Readonly<Record<string, string>>; readonly highWaterMark?: number; readonly openTimeout?: Duration.Input; readonly protocols?: string | Array<string>;}) => Layer.Layer<Socket.Socket, never, never>layerWebSocketConstructor
unstableProvides a Socket.WebSocketConstructor, using globalThis.WebSocket when
available and falling back to the ws package otherwise.
Client options objects use ws so handshake headers and subprotocols can
be supplied together.
Signature
declare const layerWebSocketConstructor: Layer.Layer<Socket.WebSocketConstructor>layerWebSocketConstructorWS
unstableProvides a Socket.WebSocketConstructor backed explicitly by the ws
package.
Supports handshake headers alongside subprotocols in client options objects.
Signature
declare const layerWebSocketConstructorWS: Layer.Layer<Socket.WebSocketConstructor>