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

@anephenix/sarus

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anephenix/sarus - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

7

__tests__/index/connectionOptions.test.ts

@@ -8,2 +8,3 @@ // File Dependencies

const arrayOfProtocols: Array<string> = ["hybi-07", "hybi-00"];
const binaryTypes: Array<string> = ["blob", "arraybuffer"];

@@ -38,2 +39,8 @@ describe("connection options", () => {

});
it("should set the binaryType of the WebSocket, if passed as an option", async () => {
const sarus: Sarus = new Sarus({ url, binaryType: binaryTypes[0] });
await server.connected;
expect(sarus.ws?.binaryType).toBe(binaryTypes[0]);
})
});

4

CHANGELOG.md
# CHANGELOG
### 0.3.2 - Saturday 16th May, 2020
- Added support for defining the binaryType on the WebSocket
### 0.3.1 - Wednesday 25th March, 2020

@@ -4,0 +8,0 @@

import { EventListenersInterface } from "./lib/validators";
export interface SarusClassParams {
url: string;
binaryType?: string;
protocols?: string | Array<string>;

@@ -17,2 +18,3 @@ eventListeners?: EventListenersInterface;

* @param {string} param0.url - The url for the WebSocket client to connect to
* @param {string} param0.binaryType - The optional type of binary data transmitted over the WebSocket connection
* @param {string\array} param0.protocols - An optional string or array of strings for the sub-protocols that the WebSocket will use

@@ -29,2 +31,3 @@ * @param {object} param0.eventListeners - An optional object containing event listener functions keyed to websocket events

url: string;
binaryType?: string;
protocols?: string | Array<string>;

@@ -147,2 +150,6 @@ eventListeners: EventListenersInterface;

attachEventListeners(): void;
/**
* Sets the binary type for the WebSocket, if such an option is set
*/
setBinaryType(): void;
}

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

* @param {string} param0.url - The url for the WebSocket client to connect to
* @param {string} param0.binaryType - The optional type of binary data transmitted over the WebSocket connection
* @param {string\array} param0.protocols - An optional string or array of strings for the sub-protocols that the WebSocket will use

@@ -52,3 +53,3 @@ * @param {object} param0.eventListeners - An optional object containing event listener functions keyed to websocket events

// Extract the properties that are passed to the class
const { url, protocols, eventListeners, reconnectAutomatically, retryProcessTimePeriod, // TODO - write a test case to check this
const { url, binaryType, protocols, eventListeners, reconnectAutomatically, retryProcessTimePeriod, // TODO - write a test case to check this
retryConnectionDelay, storageType = "memory", storageKey = "sarus" } = props;

@@ -58,2 +59,4 @@ this.eventListeners = this.auditEventListeners(eventListeners);

this.url = url;
// Sets the binaryType of the data being sent over the connection
this.binaryType = binaryType;
// Sets an optional protocols value, which can be either a string or an array of strings

@@ -195,2 +198,3 @@ this.protocols = protocols;

this.ws = new WebSocket(this.url, this.protocols);
this.setBinaryType();
this.attachEventListeners();

@@ -350,3 +354,12 @@ if (this.messages.length > 0)

}
/**
* Sets the binary type for the WebSocket, if such an option is set
*/
setBinaryType() {
const self = this;
const { binaryType } = self;
if (binaryType)
self.ws.binaryType = binaryType;
}
}
exports.default = Sarus;

4

package.json
{
"name": "@anephenix/sarus",
"version": "0.3.1",
"version": "0.3.2",
"description": "A WebSocket JavaScript library",

@@ -41,4 +41,4 @@ "main": "dist/index.js",

"dependencies": {
"@types/window-or-global": "^1.0.0"
"@types/window-or-global": "^1.0.1"
}
}

@@ -44,2 +44,3 @@ // File Dependencies

url: string;
binaryType?: string;
protocols?: string | Array<string>;

@@ -59,2 +60,3 @@ eventListeners?: EventListenersInterface;

* @param {string} param0.url - The url for the WebSocket client to connect to
* @param {string} param0.binaryType - The optional type of binary data transmitted over the WebSocket connection
* @param {string\array} param0.protocols - An optional string or array of strings for the sub-protocols that the WebSocket will use

@@ -72,2 +74,3 @@ * @param {object} param0.eventListeners - An optional object containing event listener functions keyed to websocket events

url: string;
binaryType?: string;
protocols?: string | Array<string>;

@@ -89,2 +92,3 @@ eventListeners: EventListenersInterface;

url,
binaryType,
protocols,

@@ -104,2 +108,5 @@ eventListeners,

// Sets the binaryType of the data being sent over the connection
this.binaryType = binaryType;
// Sets an optional protocols value, which can be either a string or an array of strings

@@ -257,2 +264,3 @@ this.protocols = protocols;

this.ws = new WebSocket(this.url, this.protocols);
this.setBinaryType();
this.attachEventListeners();

@@ -426,2 +434,11 @@ if (this.messages.length > 0) this.process();

}
/**
* Sets the binary type for the WebSocket, if such an option is set
*/
setBinaryType() {
const self: any = this;
const { binaryType } = self;
if (binaryType) self.ws.binaryType = binaryType;
}
}
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