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 4.1.0 to 4.1.1

19

dist/events.d.ts

@@ -23,6 +23,15 @@ export declare class Event {

}
declare type Listener = (event: Event | CloseEvent | MessageEvent) => void;
export declare type EventListener = Listener | {
handleEvent: Listener;
};
export {};
export interface WebSocketEventListenerMap {
close: (event: CloseEvent) => void | {
handleEvent: (event: CloseEvent) => void;
};
error: (event: ErrorEvent) => void | {
handleEvent: (event: ErrorEvent) => void;
};
message: (event: MessageEvent) => void | {
handleEvent: (event: MessageEvent) => void;
};
open: (event: Event) => void | {
handleEvent: (event: Event) => void;
};
}

@@ -344,2 +344,3 @@ define(function () { 'use strict';

if (this._listeners[type]) {
// @ts-ignore
this._listeners[type].push(listener);

@@ -353,2 +354,3 @@ }

if (this._listeners[type]) {
// @ts-ignore
this._listeners[type] = this._listeners[type].filter(function (l) { return l !== listener; });

@@ -464,5 +466,7 @@ }

if ('handleEvent' in listener) {
// @ts-ignore
listener.handleEvent(event);
}
else {
// @ts-ignore
listener(event);

@@ -469,0 +473,0 @@ }

@@ -344,2 +344,3 @@ 'use strict';

if (this._listeners[type]) {
// @ts-ignore
this._listeners[type].push(listener);

@@ -353,2 +354,3 @@ }

if (this._listeners[type]) {
// @ts-ignore
this._listeners[type] = this._listeners[type].filter(function (l) { return l !== listener; });

@@ -464,5 +466,7 @@ }

if ('handleEvent' in listener) {
// @ts-ignore
listener.handleEvent(event);
}
else {
// @ts-ignore
listener(event);

@@ -469,0 +473,0 @@ }

@@ -345,2 +345,3 @@ var ReconnectingWebSocket = (function () {

if (this._listeners[type]) {
// @ts-ignore
this._listeners[type].push(listener);

@@ -354,2 +355,3 @@ }

if (this._listeners[type]) {
// @ts-ignore
this._listeners[type] = this._listeners[type].filter(function (l) { return l !== listener; });

@@ -465,5 +467,7 @@ }

if ('handleEvent' in listener) {
// @ts-ignore
listener.handleEvent(event);
}
else {
// @ts-ignore
listener(event);

@@ -470,0 +474,0 @@ }

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

*/
import { CloseEvent, Event, EventListener, WebSocketEventMap } from './events';
import { CloseEvent, Event, WebSocketEventListenerMap } from './events';
export declare type Options = {

@@ -22,6 +22,6 @@ WebSocket?: any;

export declare type ListenersMap = {
error: EventListener[];
message: EventListener[];
open: EventListener[];
close: EventListener[];
error: Array<WebSocketEventListenerMap['error']>;
message: Array<WebSocketEventListenerMap['message']>;
open: Array<WebSocketEventListenerMap['open']>;
close: Array<WebSocketEventListenerMap['close']>;
};

@@ -117,7 +117,7 @@ export default class ReconnectingWebSocket {

*/
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: EventListener): void;
addEventListener<T extends keyof WebSocketEventListenerMap>(type: T, listener: WebSocketEventListenerMap[T]): void;
/**
* Removes an event listener
*/
removeEventListener<K extends keyof WebSocketEventMap>(type: K, listener: EventListener): void;
removeEventListener<T extends keyof WebSocketEventListenerMap>(type: T, listener: WebSocketEventListenerMap[T]): void;
private _debug;

@@ -124,0 +124,0 @@ private _getNextDelay;

@@ -37,4 +37,7 @@ export class Event {

type Listener = (event: Event | CloseEvent | MessageEvent) => void;
export type EventListener = Listener | {handleEvent: Listener};
export interface WebSocketEventListenerMap {
close: (event: CloseEvent) => void | {handleEvent: (event: CloseEvent) => void};
error: (event: ErrorEvent) => void | {handleEvent: (event: ErrorEvent) => void};
message: (event: MessageEvent) => void | {handleEvent: (event: MessageEvent) => void};
open: (event: Event) => void | {handleEvent: (event: Event) => void};
}
{
"name": "reconnecting-websocket",
"version": "4.1.0",
"version": "4.1.1",
"description": "Reconnecting WebSocket",

@@ -5,0 +5,0 @@ "main": "./dist/reconnecting-websocket-cjs.js",

@@ -7,3 +7,9 @@ /*!

*/
import {CloseEvent, ErrorEvent, Event, EventListener, WebSocketEventMap} from './events';
import {
CloseEvent,
ErrorEvent,
Event,
WebSocketEventListenerMap,
WebSocketEventMap,
} from './events';

@@ -48,6 +54,6 @@ const getGlobalWebSocket = (): WebSocket | undefined => {

export type ListenersMap = {
error: EventListener[];
message: EventListener[];
open: EventListener[];
close: EventListener[];
error: Array<WebSocketEventListenerMap['error']>;
message: Array<WebSocketEventListenerMap['message']>;
open: Array<WebSocketEventListenerMap['open']>;
close: Array<WebSocketEventListenerMap['close']>;
};

@@ -244,7 +250,8 @@ export default class ReconnectingWebSocket {

*/
public addEventListener<K extends keyof WebSocketEventMap>(
type: K,
listener: EventListener,
public addEventListener<T extends keyof WebSocketEventListenerMap>(
type: T,
listener: WebSocketEventListenerMap[T],
): void {
if (this._listeners[type]) {
// @ts-ignore
this._listeners[type].push(listener);

@@ -257,7 +264,8 @@ }

*/
public removeEventListener<K extends keyof WebSocketEventMap>(
type: K,
listener: EventListener,
public removeEventListener<T extends keyof WebSocketEventListenerMap>(
type: T,
listener: WebSocketEventListenerMap[T],
): void {
if (this._listeners[type]) {
// @ts-ignore
this._listeners[type] = this._listeners[type].filter(l => l !== listener);

@@ -388,6 +396,11 @@ }

private _callEventListener(event: Event | CloseEvent | MessageEvent, listener: EventListener) {
private _callEventListener<T extends keyof WebSocketEventListenerMap>(
event: WebSocketEventMap[T],
listener: WebSocketEventListenerMap[T],
) {
if ('handleEvent' in listener) {
// @ts-ignore
listener.handleEvent(event);
} else {
// @ts-ignore
listener(event);

@@ -394,0 +407,0 @@ }

Sorry, the diff of this file is not supported yet

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