A wrapper around the ws WebSocket library providing an event emitter interface, automatic reconnection with optional exponential backoff and jitter, heartbeat support, and promise-based connect/close. Currently at version 0.5.3, requires Node.js >=22 and peer dependency ws@^8.7.0. Ships TypeScript type definitions. Differentiators include a clean Emitter-based API, auto-reconnect strategies, and built-in ping/pong heartbeat.
npm install extra-websocketNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates an ExtraWebSocket, connects, handles events, enables auto-reconnect and heartbeat.
Upgrade Node.js to version 22 or later.
Use .on() and .emit() methods instead of addEventListener().
Wrap connect() in try/catch or attach rejection handler.
Ensure data is string, ArrayBufferLike, Buffer, TypedArray, or DataView.
Use the correctly spelled function if available, or use autoReconnect with custom retry logic.
Use import statements instead of require(), or run in an ESM context ("type": "module" in package.json).Create an ExtraWebSocket instance: const ws = new ExtraWebSocket(() => new WebSocket(url));
Ensure signal is not already aborted before calling connect(), or handle rejection.
Wait for the 'open' event or connect() promise to resolve before calling send().