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 1.4.0 to 1.4.2

15

build/index.js
"use strict";
var isWebSocket = function (constructor) {
return constructor
&& constructor.prototype
&& constructor.prototype.CLOSING === 2;
};
var isGlobalWebSocket = function () {
return typeof WebSocket !== 'undefined'
&& WebSocket.prototype
&& WebSocket.prototype.CLOSING === 2;
&& isWebSocket(WebSocket);
};

@@ -63,3 +67,3 @@ var getDefaultOptions = function () { return ({

.forEach(function (key) { return config[key] = options[key]; });
if (typeof config.constructor !== 'function') {
if (!isWebSocket(config.constructor)) {
throw new TypeError('WebSocket constructor not set. Set `options.constructor`');

@@ -103,3 +107,3 @@ }

// @todo move to constant
if (['addEventListener', 'removeEventListener', 'close'].indexOf(key) < 0) {
if (['addEventListener', 'removeEventListener', 'close', 'send'].indexOf(key) < 0) {
bypassProperty(ws, _this, key);

@@ -145,2 +149,5 @@ }

};
this.send = function (data) {
ws.send(data);
};
this.addEventListener = function (type, listener, options) {

@@ -147,0 +154,0 @@ if (Array.isArray(listeners[type])) {

@@ -11,6 +11,10 @@ type Options = {

const isWebSocket = constructor =>
constructor
&& constructor.prototype
&& constructor.prototype.CLOSING === 2;
const isGlobalWebSocket = () =>
typeof WebSocket !== 'undefined'
&& WebSocket.prototype
&& WebSocket.prototype.CLOSING === 2;
&& isWebSocket(WebSocket);

@@ -82,3 +86,3 @@ const getDefaultOptions = () => <Options>({

if (typeof config.constructor !== 'function') {
if (!isWebSocket(config.constructor)) {
throw new TypeError('WebSocket constructor not set. Set `options.constructor`');

@@ -118,3 +122,3 @@ }

// @todo move to constant
if (['addEventListener', 'removeEventListener', 'close'].indexOf(key) < 0) {
if (['addEventListener', 'removeEventListener', 'close', 'send'].indexOf(key) < 0) {
bypassProperty(ws, this, key);

@@ -163,2 +167,6 @@ }

this.send = (data) => {
ws.send(data)
};
this.addEventListener = (type: string, listener: EventListener, options: any) => {

@@ -165,0 +173,0 @@ if (Array.isArray(listeners[type])) {

{
"name": "reconnecting-websocket",
"version": "1.4.0",
"version": "1.4.2",
"description": "Reconnecting WebSocket",

@@ -11,3 +11,4 @@ "main": "build/index.js",

"pretest": "npm run build",
"report": "nyc report --reporter=html && opn coverage/index.html"
"report": "nyc report --reporter=html && opn coverage/index.html",
"prepublish": "npm test"
},

@@ -14,0 +15,0 @@ "keywords": [

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