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

websocket.js

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websocket.js - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

yarn.lock

2

lib/index.js
'use strict';Object.defineProperty(exports,"__esModule",{value:true});var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}var backoff=require('backoff');var WebSocketClient=function(){/**
* @param url DOMString The URL to which to connect; this should be the URL to which the WebSocket server will respond.
* @param protocols DOMString|DOMString[] Either a single protocol string or an array of protocol strings. These strings are used to indicate sub-protocols, so that a single server can implement multiple WebSocket sub-protocols (for example, you might want one server to be able to handle different types of interactions depending on the specified protocol). If you don't specify a protocol string, an empty string is assumed.
*/function WebSocketClient(url,protocols){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};_classCallCheck(this,WebSocketClient);this.url=url;this._protocols=protocols;this.reconnectEnabled=true;this.listeners={};this.backoff=backoff[options.backoff||'fibonacci'](options);this.backoff.on('backoff',this.onBackoffStart.bind(this));this.backoff.on('ready',this.onBackoffReady.bind(this));this.backoff.on('fail',this.onBackoffFail.bind(this));this.open();}_createClass(WebSocketClient,[{key:'open',value:function open(){var reconnect=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;this.isReconnect=reconnect;this.ws=new WebSocket(this.url,this._protocols);this.ws.onclose=this.onCloseCallback.bind(this);this.ws.onerror=this.onErrorCallback.bind(this);this.ws.onmessage=this.onMessageCallback.bind(this);this.ws.onopen=this.onOpenCallback.bind(this);}/**
*/function WebSocketClient(url,protocols){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};_classCallCheck(this,WebSocketClient);this.url=url;this.protocols=protocols;this.reconnectEnabled=true;this.listeners={};this.backoff=backoff[options.backoff||'fibonacci'](options);this.backoff.on('backoff',this.onBackoffStart.bind(this));this.backoff.on('ready',this.onBackoffReady.bind(this));this.backoff.on('fail',this.onBackoffFail.bind(this));this.open();}_createClass(WebSocketClient,[{key:'open',value:function open(){var reconnect=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;this.isReconnect=reconnect;this.ws=new WebSocket(this.url,this.protocols);this.ws.onclose=this.onCloseCallback.bind(this);this.ws.onerror=this.onErrorCallback.bind(this);this.ws.onmessage=this.onMessageCallback.bind(this);this.ws.onopen=this.onOpenCallback.bind(this);}/**
* @ignore

@@ -6,0 +6,0 @@ */},{key:'onBackoffStart',value:function onBackoffStart(number,delay){}/**

{
"name": "websocket.js",
"version": "0.1.7",
"version": "0.1.8",
"description": "WebSocket browser client with reconnect back-off feature.",

@@ -14,3 +14,4 @@ "repository": {

"dist": "browserify ./src/index.js -t babelify -s WebSocketClient -o dist/websocket.js && uglifyjs dist/websocket.js > dist/websocket.min.js",
"prepublish": "babel src -d lib --compact"
"prepublish": "babel src -d lib --compact",
"test": "tsc --noEmit types/test.ts"
},

@@ -23,7 +24,8 @@ "engines": {

"babel-preset-es2015": "^6.1.2",
"babelify": "^7.2.0",
"browserify": "^12.0.1",
"babelify": "^7.2.0",
"uglify-js": "^2.6.1",
"express": "^4.13.3",
"nodemon": "^1.7.1",
"typescript": "^2.3.3",
"uglify-js": "^2.6.1",
"ws": "^0.8.0"

@@ -30,0 +32,0 @@ },

@@ -11,3 +11,3 @@ var backoff = require('backoff')

this.url = url
this._protocols = protocols
this.protocols = protocols

@@ -28,3 +28,3 @@ this.reconnectEnabled = true

this.ws = new WebSocket(this.url, this._protocols)
this.ws = new WebSocket(this.url, this.protocols)
this.ws.onclose = this.onCloseCallback.bind(this)

@@ -31,0 +31,0 @@ this.ws.onerror = this.onErrorCallback.bind(this)

@@ -12,2 +12,5 @@ declare module "websocket.js" {

constructor (url: string, protocols?: string[], options?: WebSocketConnectionOptions);
url: string;
protocols?: string[];
ws: WebSocket;

@@ -17,2 +20,9 @@ binaryType: string;

listeners: {[id: string]: Function};
onclose: Function;
onerror: Function;
onmessage: Function;
onopen: Function;
onreconnect: Function;
}

@@ -19,0 +29,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