bitmex-orderbook
Advanced tools
Comparing version 1.1.1 to 1.2.0
{ | ||
"name": "bitmex-orderbook", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "BitMEX WebSocket-driven Orderbook", | ||
@@ -5,0 +5,0 @@ "main": "src/OrderBook.js", |
@@ -6,12 +6,13 @@ const crypto = require("crypto"); | ||
class BitMEXClient { | ||
constructor(options = {}) { | ||
this.socket = options.socket || null; | ||
constructor({ socket, endpoint, apiKey, apiSecret, testmode, heartbeat, ...socketOptions } = {}) { | ||
this.socketOptions = socketOptions; | ||
this.socket = socket || null; | ||
this.connected = this.socket && this.socket.readyState === WebSocket.OPEN; | ||
this.apiKey = options.apiKey || null; | ||
this.apiSecret = options.apiSecret || null; | ||
this.testmode = options.testmode === true || options.testmode === "true"; | ||
this.apiKey = apiKey || null; | ||
this.apiSecret = apiSecret || null; | ||
this.testmode = testmode === true || testmode === "true"; | ||
this.endpoint = | ||
options.endpoint || | ||
endpoint || | ||
(this.testmode ? "wss://testnet.bitmex.com/realtime" : "wss://www.bitmex.com/realtime"); | ||
this.heartbeat = options.heartbeat || 15 * 1000; | ||
this.heartbeat = heartbeat || 15 * 1000; | ||
this.subscriptions = new Set(); | ||
@@ -23,8 +24,6 @@ this.lastError = null; | ||
return new Promise((resolve, reject) => { | ||
if (this.socket) { | ||
return resolve(true); | ||
if (!this.socket) { | ||
this.socket = new WebSocket(this.endpoint, this.socketOptions); | ||
} | ||
this.socket = new WebSocket(this.endpoint); | ||
let heartbeatInterval; | ||
@@ -31,0 +30,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77388