slige/web/public/src/data.ts
2024-12-15 00:07:36 +01:00

40 lines
995 B
TypeScript

export type FlameGraphNode = {
fn: number;
acc: number;
parent: number;
children: FlameGraphNode[];
};
export async function flameGraphData(): Promise<FlameGraphNode> {
return await fetch("/api/flame-graph")
.then((v) => v.json())
.then((v) => v.flameGraph);
}
export type FlameGraphFnNames = { [key: number]: string };
export async function flameGraphFnNames(): Promise<FlameGraphFnNames> {
return await fetch("/api/flame-graph-fn-names")
.then((v) => v.json())
.then((v) => v.fnNames);
}
export async function codeData(): Promise<string> {
return await fetch("/api/source")
.then((v) => v.json())
.then((v) => v.text);
}
export type CodeCovEntry = {
index: number;
line: number;
col: number;
covers: number;
};
export async function codeCoverageData(): Promise<CodeCovEntry[]> {
return await fetch("/api/code-coverage")
.then((v) => v.json())
.then((v) => v.codeCoverage);
}