@funnest/charts 0.6.13 → 0.6.14
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/dist/index.js +20 -0
- package/dist/types.d.ts +10 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4690,6 +4690,26 @@ function combineDatafeeds(feeds) {
|
|
|
4690
4690
|
keys.map(async (key) => (await feeds[key].searchSymbols?.(query) ?? []).map((info) => outer(key, info)))
|
|
4691
4691
|
);
|
|
4692
4692
|
return results.flatMap((r) => r.status === "fulfilled" ? r.value : []);
|
|
4693
|
+
},
|
|
4694
|
+
/** Each feed's results as they arrive, always in the feeds' order (so rows don't jump). */
|
|
4695
|
+
async searchSymbolsProgressive(query, onPartial) {
|
|
4696
|
+
const slots = keys.map(() => null);
|
|
4697
|
+
const merged = () => slots.flatMap((s) => s ?? []);
|
|
4698
|
+
await Promise.allSettled(
|
|
4699
|
+
keys.map(async (key, i) => {
|
|
4700
|
+
try {
|
|
4701
|
+
slots[i] = (await feeds[key].searchSymbols?.(query) ?? []).map((info) => outer(key, info));
|
|
4702
|
+
} catch {
|
|
4703
|
+
slots[i] = [];
|
|
4704
|
+
}
|
|
4705
|
+
onPartial(merged());
|
|
4706
|
+
})
|
|
4707
|
+
);
|
|
4708
|
+
return merged();
|
|
4709
|
+
},
|
|
4710
|
+
getSparkline(symbol) {
|
|
4711
|
+
const [, feed, raw] = split(symbol);
|
|
4712
|
+
return feed.getSparkline?.(raw) ?? Promise.resolve([]);
|
|
4693
4713
|
}
|
|
4694
4714
|
};
|
|
4695
4715
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -101,6 +101,16 @@ export interface Datafeed {
|
|
|
101
101
|
onConnection?: (state: ConnectionState) => void): Unsubscribe;
|
|
102
102
|
/** Optional: powers the symbol search dialog in @funnest/charts-ui. */
|
|
103
103
|
searchSymbols?(query: string): Promise<SymbolSearchResult[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Optional: search that answers as each source comes in (`onPartial` gets everything so far),
|
|
106
|
+
* so a fast source isn't held up by a slow one. combineDatafeeds provides it.
|
|
107
|
+
*/
|
|
108
|
+
searchSymbolsProgressive?(query: string, onPartial: (results: SymbolSearchResult[]) => void): Promise<SymbolSearchResult[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Optional: recent closes for a row's mini line, oldest first. The search dialog asks only for
|
|
111
|
+
* rows on screen, after the results are shown (it never waits for these).
|
|
112
|
+
*/
|
|
113
|
+
getSparkline?(symbol: string): Promise<number[]>;
|
|
104
114
|
/** Optional: live market statistics for the market bar. */
|
|
105
115
|
subscribeQuotes?(symbol: SymbolInfo, onQuote: (quote: Quote) => void): Unsubscribe;
|
|
106
116
|
}
|