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

@relaycorp/ws-mock

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@relaycorp/ws-mock - npm Package Compare versions

Comparing version 4.0.2 to 4.1.0

11

build/main/lib/MockWebSocket.d.ts

@@ -8,5 +8,14 @@ /// <reference types="node" />

export declare class MockWebSocket extends EventEmitter {
static readonly CONNECTING: number;
static readonly OPEN: number;
static readonly CLOSING: number;
static readonly CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSING: number;
readonly CLOSED: number;
binaryType: 'nodebuffer' | 'arraybuffer';
readonly outgoingPings: PingOrPong[];
readonly outgoingPongs: PingOrPong[];
protected _readyState: number;
protected ownCloseFrame: CloseFrame | null;

@@ -16,2 +25,4 @@ protected _wasTerminated: boolean;

protected readonly ownEvents: EventEmitter;
constructor();
get readyState(): number;
send(data: WSData): void;

@@ -18,0 +29,0 @@ ping(data?: WSData, mask?: boolean, cb?: (err?: Error) => void): void;

25

build/main/lib/MockWebSocket.js

@@ -6,5 +6,10 @@ "use strict";

const stream_1 = require("stream");
const READY_STATES = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
class MockWebSocket extends events_1.EventEmitter {
constructor() {
super(...arguments);
super();
this.CONNECTING = MockWebSocket.CONNECTING;
this.OPEN = MockWebSocket.OPEN;
this.CLOSING = MockWebSocket.CLOSING;
this.CLOSED = MockWebSocket.CLOSED;
// tslint:disable-next-line:readonly-keyword

@@ -17,2 +22,4 @@ this.binaryType = 'nodebuffer';

// tslint:disable-next-line:readonly-keyword
this._readyState = MockWebSocket.CONNECTING;
// tslint:disable-next-line:readonly-keyword
this.ownCloseFrame = null;

@@ -24,3 +31,10 @@ // tslint:disable-next-line:readonly-keyword

this.ownEvents = new events_1.EventEmitter();
this.once('open', () => {
// tslint:disable-next-line:no-object-mutation
this._readyState = MockWebSocket.OPEN;
});
}
get readyState() {
return this._readyState;
}
send(data) {

@@ -63,2 +77,4 @@ this.requireOpenConnection();

// tslint:disable-next-line:no-object-mutation
this._readyState = MockWebSocket.CLOSED;
// tslint:disable-next-line:no-object-mutation
this.ownCloseFrame = { code, reason };

@@ -85,2 +101,4 @@ this.ownEvents.emit('close', this.ownCloseFrame);

// tslint:disable-next-line:no-object-mutation
this._readyState = MockWebSocket.CLOSED;
// tslint:disable-next-line:no-object-mutation
this._wasTerminated = true;

@@ -119,2 +137,3 @@ this.ownEvents.emit('termination');

requireOpenConnection() {
// TODO: Use this.readyState
if (this.ownCloseFrame) {

@@ -129,2 +148,6 @@ throw new Error('Connection was closed');

exports.MockWebSocket = MockWebSocket;
MockWebSocket.CONNECTING = READY_STATES.indexOf('CONNECTING');
MockWebSocket.OPEN = READY_STATES.indexOf('OPEN');
MockWebSocket.CLOSING = READY_STATES.indexOf('CLOSING');
MockWebSocket.CLOSED = READY_STATES.indexOf('CLOSED');
async function waitForEvent(eventName, eventEmitter) {

@@ -131,0 +154,0 @@ return new Promise((resolve) => eventEmitter.once(eventName, resolve));

@@ -8,5 +8,14 @@ /// <reference types="node" />

export declare class MockWebSocket extends EventEmitter {
static readonly CONNECTING: number;
static readonly OPEN: number;
static readonly CLOSING: number;
static readonly CLOSED: number;
readonly CONNECTING: number;
readonly OPEN: number;
readonly CLOSING: number;
readonly CLOSED: number;
binaryType: 'nodebuffer' | 'arraybuffer';
readonly outgoingPings: PingOrPong[];
readonly outgoingPongs: PingOrPong[];
protected _readyState: number;
protected ownCloseFrame: CloseFrame | null;

@@ -16,2 +25,4 @@ protected _wasTerminated: boolean;

protected readonly ownEvents: EventEmitter;
constructor();
get readyState(): number;
send(data: WSData): void;

@@ -18,0 +29,0 @@ ping(data?: WSData, mask?: boolean, cb?: (err?: Error) => void): void;

import { EventEmitter } from 'events';
import { Duplex } from 'stream';
const READY_STATES = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
export class MockWebSocket extends EventEmitter {
static CONNECTING = READY_STATES.indexOf('CONNECTING');
static OPEN = READY_STATES.indexOf('OPEN');
static CLOSING = READY_STATES.indexOf('CLOSING');
static CLOSED = READY_STATES.indexOf('CLOSED');
CONNECTING = MockWebSocket.CONNECTING;
OPEN = MockWebSocket.OPEN;
CLOSING = MockWebSocket.CLOSING;
CLOSED = MockWebSocket.CLOSED;
// tslint:disable-next-line:readonly-keyword

@@ -11,2 +20,4 @@ binaryType = 'nodebuffer';

// tslint:disable-next-line:readonly-keyword
_readyState = MockWebSocket.CONNECTING;
// tslint:disable-next-line:readonly-keyword
ownCloseFrame = null;

@@ -18,2 +29,12 @@ // tslint:disable-next-line:readonly-keyword

ownEvents = new EventEmitter();
constructor() {
super();
this.once('open', () => {
// tslint:disable-next-line:no-object-mutation
this._readyState = MockWebSocket.OPEN;
});
}
get readyState() {
return this._readyState;
}
send(data) {

@@ -56,2 +77,4 @@ this.requireOpenConnection();

// tslint:disable-next-line:no-object-mutation
this._readyState = MockWebSocket.CLOSED;
// tslint:disable-next-line:no-object-mutation
this.ownCloseFrame = { code, reason };

@@ -78,2 +101,4 @@ this.ownEvents.emit('close', this.ownCloseFrame);

// tslint:disable-next-line:no-object-mutation
this._readyState = MockWebSocket.CLOSED;
// tslint:disable-next-line:no-object-mutation
this._wasTerminated = true;

@@ -112,2 +137,3 @@ this.ownEvents.emit('termination');

requireOpenConnection() {
// TODO: Use this.readyState
if (this.ownCloseFrame) {

@@ -114,0 +140,0 @@ throw new Error('Connection was closed');

2

package.json
{
"name": "@relaycorp/ws-mock",
"version": "4.0.2",
"version": "4.1.0",
"author": {

@@ -5,0 +5,0 @@ "email": "no-reply@relaycorp.tech",

Sorry, the diff of this file is not supported yet

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