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.0 to 3.0.1

12

dist/index.js

@@ -54,2 +54,3 @@ "use strict";

var shouldRetry = true;
var savedOnClose = null;
var listeners = {};

@@ -136,2 +137,5 @@ // require new to construct

reassignEventListeners(ws, oldWs, listeners);
// because when closing with fastClose=true, it is saved and set to null to avoid double calls
ws.onclose = ws.onclose || savedOnClose;
savedOnClose = null;
};

@@ -156,5 +160,7 @@ log('init');

// execute close listeners soon with a fake closeEvent
// and remove all close listeners from the WS instance
// so they don't get fired on the real close.
// and remove them from the WS instance so they
// don't get fired on the real close.
handleClose();
ws.removeEventListener('close', handleClose);
// run and remove level2
if (Array.isArray(listeners.close)) {

@@ -167,3 +173,5 @@ listeners.close.forEach(function (_a) {

}
// remove level0
if (ws.onclose) {
savedOnClose = ws.onclose;
ws.onclose(fakeCloseEvent_1);

@@ -170,0 +178,0 @@ ws.onclose = null;

27

index.ts

@@ -1,10 +0,1 @@

/*
Ready state constants
https://developer.mozilla.org/en-US/docs/Web/API/WebSocket#Ready_state_constants
CONNECTING 0 The connection is not yet open.
OPEN 1 The connection is open and ready to communicate.
CLOSING 2 The connection is in the process of closing.
CLOSED 3 The connection is closed or couldn't be opened.
*/
type Options = {

@@ -57,3 +48,3 @@ constructor?: new(url: string, protocols?: string | string[]) => WebSocket;

const reassignEventListeners = (ws: WebSocket, oldWs, listeners) => {
const reassignEventListeners = (ws: WebSocket, oldWs: WebSocket, listeners) => {
Object.keys(listeners).forEach(type => {

@@ -79,2 +70,3 @@ listeners[type].forEach(([listener, options]) => {

let shouldRetry = true;
let savedOnClose = null;
const listeners: any = {};

@@ -164,2 +156,6 @@

reassignEventListeners(ws, oldWs, listeners);
// because when closing with fastClose=true, it is saved and set to null to avoid double calls
ws.onclose = ws.onclose || savedOnClose;
savedOnClose = null;
};

@@ -186,7 +182,7 @@

// execute close listeners soon with a fake closeEvent
// and remove all close listeners from the WS instance
// so they don't get fired on the real close.
// and remove them from the WS instance so they
// don't get fired on the real close.
handleClose();
ws.removeEventListener('close', handleClose);
// run and remove level2
if (Array.isArray(listeners.close)) {

@@ -198,4 +194,5 @@ listeners.close.forEach(([listener, options]) => {

}
// remove level0
if (ws.onclose) {
savedOnClose = ws.onclose;
ws.onclose(fakeCloseEvent);

@@ -202,0 +199,0 @@ ws.onclose = null;

{
"name": "reconnecting-websocket",
"version": "3.0.0",
"version": "3.0.1",
"description": "Reconnecting WebSocket",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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