Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

reconnecting-websocket

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reconnecting-websocket - npm Package Compare versions

Comparing version 3.0.7 to 3.1.0

2

dist/index.d.ts

@@ -1,2 +0,2 @@

declare const ReconnectingWebsocket: (url: string, protocols?: string | string[], options?: {
declare const ReconnectingWebsocket: (url: string | (() => string), protocols?: string | string[], options?: {
constructor?: new (url: string, protocols?: string | string[]) => WebSocket;

@@ -3,0 +3,0 @@ maxReconnectionDelay?: number;

@@ -117,3 +117,4 @@ "use strict";

var oldWs = ws;
ws = new config.constructor(url, protocols);
var wsUrl = (typeof url === 'function') ? url() : url;
ws = new config.constructor(wsUrl, protocols);
connectingTimeout = setTimeout(function () {

@@ -120,0 +121,0 @@ log('timeout');

declare module "index" {
const ReconnectingWebsocket: (url: string, protocols?: string | string[], options?: {
const ReconnectingWebsocket: (url: string | (() => string), protocols?: string | string[], options?: {
constructor?: new (url: string, protocols?: string | string[]) => WebSocket;

@@ -4,0 +4,0 @@ maxReconnectionDelay?: number;

@@ -118,3 +118,4 @@ define("index", ["require", "exports"], function (require, exports) {

var oldWs = ws;
ws = new config.constructor(url, protocols);
var wsUrl = (typeof url === 'function') ? url() : url;
ws = new config.constructor(wsUrl, protocols);
connectingTimeout = setTimeout(function () {

@@ -121,0 +122,0 @@ log('timeout');

@@ -66,3 +66,3 @@ /*!

const ReconnectingWebsocket = function(
url: string,
url: string | (() => string),
protocols?: string|string[],

@@ -138,3 +138,4 @@ options = <Options>{}

const oldWs = ws;
ws = new (<any>config.constructor)(url, protocols);
const wsUrl = (typeof url === 'function') ? url() : url;
ws = new (<any>config.constructor)(wsUrl, protocols);

@@ -141,0 +142,0 @@ connectingTimeout = setTimeout(() => {

{
"name": "reconnecting-websocket",
"version": "3.0.7",
"version": "3.1.0",
"description": "Reconnecting WebSocket",

@@ -30,10 +30,10 @@ "main": "dist/index.js",

"devDependencies": {
"ava": "^0.20.0",
"ava": "^0.21.0",
"coveralls": "^2.13.1",
"html5-websocket": "^1.0.0",
"nyc": "^11.0.3",
"html5-websocket": "^2.0.0",
"nyc": "^11.1.0",
"opn-cli": "^3.1.0",
"rimraf": "^2.5.4",
"typescript": "^2.4.1",
"ws": "^3.0.0"
"typescript": "^2.4.2",
"ws": "^3.1.0"
},

@@ -40,0 +40,0 @@ "dependencies": {},

@@ -20,4 +20,5 @@ # Reconnecting WebSocket

- Debug mode
- Fast close (new in version 3)
- Fast close
- AMD build available (see dist folder)
- Allows changing server URL

@@ -65,2 +66,17 @@ ## Install

### Update URL
The `url` parameter also accepts a `function` so you have a chance to update the URL before connecting:
```
const ReconnectingWebSocket = require('reconnecting-websocket');
const urls = ['ws://my.site.com', 'ws://your.site.com', 'ws://their.site.com'];
let urlIndex = 0;
// Round robin url provider
const getUrl = () => urls[urlIndex++ % urls.length];
const rws = new ReconnectingWebSocket(getUrl);
```
### Configure

@@ -67,0 +83,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc