NodeSocket
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
Added in v4.0.0
Source
Signature
declare const layerWebSocket: (
url: string | Effect.Effect<string>,
options?: {
readonly closeCodeIsError?: (code: number) => boolean;
readonly openTimeout?: Duration.Input;
readonly protocols?: string | Array<string>;
},
) => Layer.Layer<Socket.Socket, never, never>;layerWebSocketConstructor
Added in v4.0.0
Source
Provides a Socket.WebSocketConstructor, using globalThis.WebSocket when available and falling back to the ws package otherwise.
Signature
declare const layerWebSocketConstructor: Layer.Layer<Socket.WebSocketConstructor>;layerWebSocketConstructorWS
Added in v4.0.0
Source
Provides a Socket.WebSocketConstructor backed explicitly by the ws package.
Signature
declare const layerWebSocketConstructorWS: Layer.Layer<Socket.WebSocketConstructor>;
Creates a
Socket.Socketlayer for a WebSocket URL using the Node WebSocket constructor layer, honoring protocol, open-timeout, and close-code error options.