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

@binquant/exchange

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@binquant/exchange - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

46

lib/binance/ws.js

@@ -457,16 +457,26 @@ "use strict";

this.isReady = false;
this.isReconnecting = false;
this.connect();
}
async connect() {
var _a, _b;
this.logger.info('ws connecting');
// ensure last ws clear
if ((_a = this.ws) === null || _a === void 0 ? void 0 : _a.onClear) {
(_b = this.ws) === null || _b === void 0 ? void 0 : _b.onClear();
// ensure ws closed
this.ws.terminate();
}
this.listenKey = await this.options.createListenKey();
const ws = (this.ws = new WebSocket(this.url));
ws.on('error', (error) => {
const onError = (error) => {
this.logger.info('ws error:', error);
});
ws.on('close', (...args) => {
};
const onClose = (...args) => {
this.logger.info('ws close:', JSON.stringify(args));
this.reconnect();
});
ws.on('open', () => {
if (!this.isReconnecting) {
this.reconnect();
}
};
const onOpen = () => {
this.isReady = true;

@@ -480,12 +490,25 @@ if (this.subscribeQueue.length !== null) {

this.logger.info('ws connected(open)');
});
ws.on('ping', () => {
};
const onPing = () => {
this.logger.info('ws ping');
ws.emit('pong');
});
ws.on('message', (message) => {
};
const onMessage = (message) => {
this.emit('message', JSON.parse(message));
});
};
ws.on('error', onError);
ws.on('close', onClose);
ws.on('open', onOpen);
ws.on('ping', onPing);
ws.on('message', onMessage);
ws.onClear = () => {
ws.off('error', onError);
ws.off('close', onClose);
ws.off('open', onOpen);
ws.off('ping', onPing);
ws.off('message', onMessage);
};
}
reconnect() {
this.isReconnecting = true;
// reconnect

@@ -497,2 +520,3 @@ // @TODO resubscribes

this.logger.info('ws reconnect all subscribes:', JSON.stringify(this.subscribeQueue));
this.isReconnecting = false;
// connect

@@ -499,0 +523,0 @@ this.connect();

{
"name": "@binquant/exchange",
"version": "0.0.12",
"version": "0.0.13",
"description": "Exchanges Client",

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

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