laplace-api 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laplace-api",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Client library for Laplace API for the US stock market and BIST (Istanbul stock market) fundamental financial data.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -244,10 +244,12 @@ export class LivePriceWebSocketClient {
244
244
  this.reconnectTimeout = setTimeout(async () => {
245
245
  try {
246
246
  await this.connect(url);
247
+
248
+ this.isClosed = false
249
+
247
250
  const activeSymbols = this.getActiveSymbols();
248
- if (activeSymbols.length > 0) {
249
- this.addSymbols(activeSymbols);
250
- }
251
+ this.addSymbols(activeSymbols);
252
+
251
253
  if (this.reconnectTimeout) {
252
254
  clearTimeout(this.reconnectTimeout);
253
255
  this.reconnectTimeout = null;
@@ -273,18 +275,14 @@ export class LivePriceWebSocketClient {
273
275
  symbolsToAdd.push(symbol);
274
276
  }
275
277
  }
276
- if (symbolsToAdd.length > 0) {
277
- this.addSymbols(symbolsToAdd);
278
- }
278
+ this.addSymbols(symbolsToAdd);
279
279
 
280
280
  return () => {
281
281
  this.subscriptions.delete(subscriptionId);
282
282
  const symbolsForRemove = symbols.filter(
283
283
  (s) => this.getHandlersForSymbol(s).length === 0
284
284
  );
285
- if (symbolsForRemove.length > 0) {
286
- this.removeSymbols(symbolsForRemove);
287
- }
285
+ this.removeSymbols(symbolsForRemove);
288
286
  };
289
287
  }
290
288
 
@@ -297,6 +295,8 @@ export class LivePriceWebSocketClient {
297
295
  }
298
296
 
299
297
  private async removeSymbols(symbols: string[]) {
298
+ if (symbols.length === 0) return;
299
+
300
300
  if (!this.ws) {
301
301
  throw new WebSocketError(
302
302
  "WebSocket is not initialized",
@@ -319,6 +319,8 @@ export class LivePriceWebSocketClient {
319
319
  }
320
320
 
321
321
  private async addSymbols(symbols: string[]) {
322
+ if (symbols.length === 0) return;
323
+
322
324
  if (!this.ws) {
323
325
  throw new WebSocketError(
324
326
  "WebSocket is not initialized",