BunSocket
Bun platform socket entry point for Effect sockets.
This module re-exports the shared Node socket constructors for TCP clients, Unix domain socket clients, and adapters from existing Node Duplex streams. It also provides Bun WebSocket layers using globalThis.WebSocket, including a constructor layer and a Socket.Socket layer for a WebSocket URL.
Layers
layerWebSocket
Added in v4.0.0
Source
Signature
declare const layerWebSocket: ( url: string | 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 backed by Bun's global WebSocket implementation.
Signature
declare const layerWebSocketConstructor: Layer.Layer<Socket.WebSocketConstructor>;
Creates a
Socket.Socketlayer for a WebSocket URL using Bun's globalWebSocketconstructor, honoring protocol, open-timeout, and close-code error options.