general: snapshot

This commit is contained in:
k
2024-06-25 14:46:23 +02:00
parent 7604787fbb
commit 20a51f980b
27 changed files with 342 additions and 225 deletions

View File

@@ -0,0 +1,40 @@
import { createResourceDataset } from "./resource";
export { averages } from "./consts/averages";
export function createScaleDatasets<Scale extends ResourceScale>({
scale,
setActiveResources,
groupedKeysToURLPath,
}: {
scale: Scale;
setActiveResources: Setter<Set<ResourceDataset<any, any>>>;
groupedKeysToURLPath: GroupedKeysToURLPath[Scale];
}) {
type Key = keyof typeof groupedKeysToURLPath;
type ResourceData = ReturnType<typeof createResourceDataset<Scale>>;
type ResourceDatasets = Record<Exclude<Key, "ohlc">, ResourceData>;
const datasets = groupedKeysToURLPath as any as ResourceDatasets;
for (const key in groupedKeysToURLPath) {
if ((key as Key) !== "ohlc") {
datasets[key as unknown as Exclude<Key, "ohlc">] = createResourceDataset({
scale,
path: groupedKeysToURLPath[key as Key] as any,
setActiveResources,
});
}
}
const price = createResourceDataset<Scale, OHLC>({
scale,
path: `/${scale}-to-ohlc`,
setActiveResources,
});
Object.assign(datasets, { price });
return datasets;
}