A lightweight WebSocket client library for Node.js built on the `ws` library (peer dependency v8.11.0+). Provides a clean, Promise-based API for WebSocket connections, message handling, and automatic reconnection. Current stable version is 2.0.14, released with TypeScript declarations included. Differentiates from raw `ws` by offering higher-level abstractions like event emitters, reconnection logic, and simpler error handling. Suitable for real-time applications, chat systems, and live data feeds.
npm install elmer-socketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic WebSocket connection with event handlers for open, message, close, and error.
Update to new class-based API: use `new ElmerSocket(url, options)` instead of `ElmerSocket(url, options)`.
Run `npm install ws@^8.11.0` to satisfy peer dependency.
Replace `ws.readyState` with `ws.status`.
Use `ws.bufferedBytes()` method instead.
Always send messages inside the 'open' event callback or after checking `ws.readyState === ws.OPEN` (use `ws.status` in v2).
Use a browser-compatible WebSocket library like `isomorphic-ws` if targeting the browser.
Run `npm install ws@^8.11.0` in your project.
Instantiate with `new ElmerSocket(url, options)`.
Call `ws.send()` only inside the 'open' event handler or after ensuring the connection is open using `ws.status`.
Use the default import: `import ElmerSocket from 'elmer-socket'`.