New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@open-rpc/client-js

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-rpc/client-js - npm Package Compare versions

Comparing version 1.5.2 to 1.6.0

7

build/Client.d.ts
import RequestManager from "./RequestManager";
import { JSONRPCError } from "./Error";
import { IClient, RequestArguments, NotificationArguments } from "./ClientInterface";
import { IJSONRPCNotification } from "./Request";
/**

@@ -61,5 +62,9 @@ * OpenRPC Client JS is a browser-compatible JSON-RPC client with multiple transports and

notify(requestObject: NotificationArguments): Promise<any>;
onNotification(callback: (data: any) => void): void;
onNotification(callback: (data: IJSONRPCNotification) => void): void;
onError(callback: (data: JSONRPCError) => void): void;
/**
* Close connection
*/
close(): void;
}
export default Client;

@@ -135,4 +135,10 @@ "use strict";

};
/**
* Close connection
*/
Client.prototype.close = function () {
this.requestManager.close();
};
return Client;
}());
exports.default = Client;

@@ -0,1 +1,2 @@

import { IJSONRPCNotification } from "./Request";
interface Arguments {

@@ -11,3 +12,5 @@ readonly method: string;

notify(args: NotificationArguments): Promise<unknown>;
close(): void;
onNotification(callback: (data: IJSONRPCNotification) => void): void;
}
export {};

@@ -61,2 +61,8 @@ "use strict";

});
describe("can close", function () {
var emitter = new events_1.EventEmitter();
var rm = new RequestManager_1.default([new EventEmitterTransport_1.default(emitter, "from1", "to1")]);
var c = new _1.Client(rm);
c.close();
});
});

@@ -94,3 +94,5 @@ "use strict";

RequestManager.prototype.close = function () {
this.requestChannel.removeAllListeners();
this.transports.forEach(function (transport) {
transport.unsubscribe();
transport.close();

@@ -97,0 +99,0 @@ });

@@ -22,2 +22,3 @@ /// <reference types="node" />

subscribe(event: TransportEventName, handler: ITransportEvents[TransportEventName]): void;
unsubscribe(event?: TransportEventName, handler?: ITransportEvents[TransportEventName]): EventEmitter | undefined;
protected parseData(data: JSONRPCRequestData): import("../Request").IJSONRPCRequest | import("../Request").IJSONRPCNotification | (import("../Request").IJSONRPCRequest | import("../Request").IJSONRPCNotification)[];

@@ -24,0 +25,0 @@ }

@@ -15,2 +15,10 @@ "use strict";

};
Transport.prototype.unsubscribe = function (event, handler) {
if (!event) {
return this.transportRequestManager.transportEventChannel.removeAllListeners();
}
if (event && handler) {
this.transportRequestManager.transportEventChannel.removeListener(event, handler);
}
};
Transport.prototype.parseData = function (data) {

@@ -17,0 +25,0 @@ if (data instanceof Array) {

@@ -0,1 +1,13 @@

# [1.6.0](https://github.com/open-rpc/client-js/compare/1.5.2...1.6.0) (2020-10-19)
### Bug Fixes
* **Client:** add close test ([0139391](https://github.com/open-rpc/client-js/commit/01393916731d12195a7719784467aee8ef48cb4c))
### Features
* add `close` method Client to close connection and cleanup event listeners ([0155c81](https://github.com/open-rpc/client-js/commit/0155c8109edf1ffc6508de3125072afc418de8b4))
## [1.5.2](https://github.com/open-rpc/client-js/compare/1.5.1...1.5.2) (2020-10-09)

@@ -2,0 +14,0 @@

2

package.json
{
"name": "@open-rpc/client-js",
"version": "1.5.2",
"version": "1.6.0",
"description": " A browser-compatible JSON-RPC client with multiple transports.",

@@ -5,0 +5,0 @@ "main": "build/index.js",

@@ -112,2 +112,3 @@ # OpenRPC Client JS

console.log("DONE");
client.close();
});

@@ -114,0 +115,0 @@

import RequestManager from "./RequestManager";
import { JSONRPCError } from "./Error";
import { IClient, RequestArguments, NotificationArguments } from "./ClientInterface";
import { IJSONRPCNotification } from "./Request";

@@ -83,3 +84,3 @@ /**

public onNotification(callback: (data: any) => void) {
public onNotification(callback: (data: IJSONRPCNotification) => void) {
this.requestManager.requestChannel.addListener("notification", callback);

@@ -91,4 +92,11 @@ }

}
/**
* Close connection
*/
public close() {
this.requestManager.close();
}
}
export default Client;

@@ -0,1 +1,3 @@

import { IJSONRPCNotification } from "./Request";
interface Arguments {

@@ -15,2 +17,4 @@ readonly method: string;

notify(args: NotificationArguments): Promise<unknown>;
close(): void;
onNotification(callback: (data: IJSONRPCNotification) => void): void;
}

@@ -64,2 +64,9 @@ import { Client } from ".";

describe("can close", () => {
const emitter = new EventEmitter();
const rm = new RequestManager([new EventEmitterTransport(emitter, "from1", "to1")]);
const c = new Client(rm);
c.close();
});
});

@@ -62,3 +62,5 @@ import { Transport } from "./transports/Transport";

public close(): void {
this.requestChannel.removeAllListeners();
this.transports.forEach((transport) => {
transport.unsubscribe();
transport.close();

@@ -65,0 +67,0 @@ });

@@ -38,2 +38,10 @@ import {

}
public unsubscribe(event?: TransportEventName, handler?: ITransportEvents[TransportEventName]) {
if (!event) {
return this.transportRequestManager.transportEventChannel.removeAllListeners();
}
if (event && handler) {
this.transportRequestManager.transportEventChannel.removeListener(event, handler);
}
}
protected parseData(data: JSONRPCRequestData) {

@@ -40,0 +48,0 @@ if (data instanceof Array) {

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