laplace-api 1.0.8 → 1.0.10

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.0.8",
3
+ "version": "1.0.10",
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": {
@@ -2,21 +2,18 @@ import { Client } from './client';
2
2
  import { Region } from './collections';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
4
 
5
- async function* getLivePrice<T>(
5
+ function getLivePrice<T>(
6
6
  client: Client,
7
7
  symbols: string[],
8
- region: Region
9
- ): AsyncGenerator<T, void, undefined> {
10
- const streamId = uuidv4();
8
+ region: Region,
9
+ streamId: string = uuidv4(),
10
+ ): {
11
+ events: AsyncIterable<T>,
12
+ cancel: () => void
13
+ } {
11
14
  const url = `${client["baseUrl"]}/api/v1/stock/price/live?filter=${symbols.join(',')}&region=${region}&stream=${streamId}`;
12
15
 
13
- const { events, cancel } = client.sendSSERequest<T>(url);
14
-
15
- try {
16
- yield* events;
17
- } finally {
18
- cancel();
19
- }
16
+ return client.sendSSERequest<T>(url);
20
17
  }
21
18
 
22
19
  export interface BISTStockLiveData {
@@ -32,11 +29,25 @@ export interface USStockLiveData {
32
29
  }
33
30
 
34
31
  export class LivePriceClient extends Client {
35
- getLivePriceForBIST(symbols: string[], region: Region): AsyncGenerator<BISTStockLiveData, void, undefined> {
36
- return getLivePrice<BISTStockLiveData>(this, symbols, region);
32
+ getLivePriceForBIST(
33
+ symbols: string[],
34
+ region: Region,
35
+ streamId?: string,
36
+ ): {
37
+ events: AsyncIterable<BISTStockLiveData>,
38
+ cancel: () => void
39
+ } {
40
+ return getLivePrice<BISTStockLiveData>(this, symbols, region, streamId);
37
41
  }
38
42
 
39
- getLivePriceForUS(symbols: string[], region: Region): AsyncGenerator<USStockLiveData, void, undefined> {
40
- return getLivePrice<USStockLiveData>(this, symbols, region);
43
+ getLivePriceForUS(
44
+ symbols: string[],
45
+ region: Region,
46
+ streamId?: string,
47
+ ): {
48
+ events: AsyncIterable<USStockLiveData>,
49
+ cancel: () => void
50
+ } {
51
+ return getLivePrice<USStockLiveData>(this, symbols, region, streamId);
41
52
  }
42
53
  }